Skip to content

Commit e3e2283

Browse files
committed
Exit with code 1 on error
1 parent 6e6fbba commit e3e2283

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

dist/Compiler.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function compile(fileNames, options, projectRoot) {
77
// Verify target
88
if (options.target != "lua") {
99
console.error("Wrong compilation target! Add \"target\": \"lua\" to your tsconfig.json!");
10-
process.exit();
10+
process.exit(1);
1111
}
1212
var program = ts.createProgram(fileNames, options);
1313
var checker = program.getTypeChecker();
@@ -26,7 +26,7 @@ function compile(fileNames, options, projectRoot) {
2626
// If there are errors dont emit
2727
if (diagnostics.filter(function (diag) { return diag.category == ts.DiagnosticCategory.Error; }).length > 0) {
2828
console.log("Stopping compilation process because of errors.");
29-
process.exit();
29+
process.exit(1);
3030
}
3131
program.getSourceFiles().forEach(function (sourceFile) {
3232
if (!sourceFile.isDeclarationFile) {
@@ -53,14 +53,15 @@ function compile(fileNames, options, projectRoot) {
5353
console.error("Encountered error parsing file: " + exception.message);
5454
console.error(sourceFile.fileName + " line: " + (1 + pos.line) + " column: " + pos.character);
5555
console.error(exception.stack);
56+
process.exit(1);
5657
}
5758
else {
5859
throw exception;
5960
}
6061
}
6162
}
6263
});
63-
process.exit();
64+
process.exit(0);
6465
}
6566
function printAST(node, indent) {
6667
var indentStr = "";

src/Compiler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function compile(fileNames: string[], options: ts.CompilerOptions, projectRoot:
88
// Verify target
99
if ((<string><any>options.target) != "lua") {
1010
console.error("Wrong compilation target! Add \"target\": \"lua\" to your tsconfig.json!");
11-
process.exit();
11+
process.exit(1);
1212
}
1313

1414
let program = ts.createProgram(fileNames, options);
@@ -30,7 +30,7 @@ function compile(fileNames: string[], options: ts.CompilerOptions, projectRoot:
3030
// If there are errors dont emit
3131
if (diagnostics.filter(diag => diag.category == ts.DiagnosticCategory.Error).length > 0) {
3232
console.log("Stopping compilation process because of errors.");
33-
process.exit();
33+
process.exit(1);
3434
}
3535

3636
program.getSourceFiles().forEach(sourceFile => {
@@ -59,14 +59,15 @@ function compile(fileNames: string[], options: ts.CompilerOptions, projectRoot:
5959
console.error("Encountered error parsing file: " + exception.message);
6060
console.error(sourceFile.fileName + " line: " + (1 + pos.line) + " column: " + pos.character);
6161
console.error(exception.stack);
62+
process.exit(1);
6263
} else {
6364
throw exception;
6465
}
6566
}
6667
}
6768
});
6869

69-
process.exit();
70+
process.exit(0);
7071
}
7172

7273
function printAST(node: ts.Node, indent: number) {

0 commit comments

Comments
 (0)