Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Analyze succeeds even if ts output config is missing. #788

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/steps/build/compileTypeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const compileTypeScript = async function ({
const parsedTsConfig = ts.parseJsonSourceFileConfigFileContent(tsConfigSourceFile, ts.sys, applicationRoot, undefined, tsConfigPath);
const compilerOptions = parsedTsConfig.options;

if (!compilerOptions.outDir) {
if (!compilerOptions.outDir && !noEmit) {
return error(new errors.TypeScriptOutputConfigurationMissing());
}

Expand All @@ -45,8 +45,8 @@ const compileTypeScript = async function ({
options: compilerOptions
});

if (compilerOptions.incremental !== true) {
await fs.promises.rm(compilerOptions.outDir, { recursive: true, force: true });
if (compilerOptions.incremental !== true && !noEmit) {
await fs.promises.rm(compilerOptions.outDir!, { recursive: true, force: true });
}

let emitResult: EmitResult | undefined;
Expand Down
14 changes: 14 additions & 0 deletions test/integration/analyzeTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,18 @@ suite('analyze', function (): void {
assert.that(stripAnsi(error.stderr)).is.containing('The given license is not a valid SPDX expression.');
}
);

testWithFixture(
'does not fail when outDir is not configured in tsconfig',
[ 'analyze', 'without-output-config' ],
async (fixture): Promise<void> => {
const roboterResult = await runCommand('npx roboter analyze', {
cwd: fixture.absoluteTestDirectory,
silent: true
});

assert.that(roboterResult).is.aValue();
assert.that(roboterResult.unwrapOrThrow().exitCode).is.equalTo(0);
}
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "es/node"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "npm-package-json-lint-config-tnw/lib.json",
"rules": {
"prefer-alphabetical-devDependencies": "off"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compatibleLicenses": [
"0BSD",
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"CC-BY-3.0",
"CC-BY-4.0",
"CC0-1.0",
"MIT",
"ISC",
"Python-2.0"
]
}
16 changes: 16 additions & 0 deletions test/shared/fixtures/analyze/without-output-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "test-package",
"version": "0.0.1",
"description": "a test-package.",
"contributors": [],
"private": false,
"main": "",
"types": "",
"engines": {},
"dependencies": {},
"devDependencies": {},
"scripts": {},
"repository": {},
"keywords": [],
"license": "MIT"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const add = function (left: number, right: number): number {
return left + right;
};

const sum = add(23, 42);

// eslint-disable-next-line no-console
console.log(sum);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"baseUrl": "./",
"declaration": true,
"esModuleInterop": true,
"lib": [ "dom", "esnext" ],
"module": "commonjs",
"resolveJsonModule": true,
"strict": true,
"target": "es2019"
},
"include": [
"./**/*.ts"
]
}