Skip to content

Commit 3557a4a

Browse files
committed
fix(exit): integrate exit module
1 parent af78764 commit 3557a4a

12 files changed

Lines changed: 41 additions & 23 deletions

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@types/autoprefixer": "^9.1.0",
6262
"@types/chokidar": "^1.7.4",
6363
"@types/cssnano": "^4.0.0",
64+
"@types/exit": "^0.1.30",
6465
"@types/fs-extra": "^5.0.0",
6566
"@types/glob": "^7.1.1",
6667
"@types/graceful-fs": "^4.1.2",
@@ -82,6 +83,7 @@
8283
"cssnano": "4.1.7",
8384
"estree-walker": "0.5.2",
8485
"execa": "^0.8.0",
86+
"exit": "^0.1.2",
8587
"fast-deep-equal": "^2.0.1",
8688
"fs-extra": "^5.0.0",
8789
"glob": "7.1.3",

scripts/build-dev-server.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ if (success) {
3737
'path',
3838
'querystring',
3939
'url',
40-
'zlib'
40+
'zlib',
41+
'../sys/node/graceful-fs.js'
4142
],
4243
plugins: [
44+
(() => {
45+
return {
46+
resolveId(importee) {
47+
if (importee === 'graceful-fs') {
48+
return '../sys/node/graceful-fs.js';
49+
}
50+
}
51+
}
52+
})(),
4353
rollupResolve(),
4454
rollupCommonjs()
4555
],

scripts/build-prod.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fs.emptyDirSync(DIST_LICENSES);
3535
'autoprefixer',
3636
'cssnano',
3737
'css-what',
38+
'exit',
3839
'glob',
3940
'graceful-fs',
4041
'is-glob',

src/cli/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getConfigFilePath } from './cli-utils';
33
import { parseFlags } from './parse-flags';
44
import { runTask } from './run-task';
55
import { shouldIgnoreError } from '../compiler/util';
6+
import exit from 'exit';
67

78

89
export async function run(process: NodeJS.Process, sys: d.StencilSystem, logger: d.Logger) {
@@ -29,7 +30,7 @@ export async function run(process: NodeJS.Process, sys: d.StencilSystem, logger:
2930

3031
} catch (e) {
3132
logger.error(e);
32-
process.exit(1);
33+
exit(1);
3334
}
3435

3536
try {
@@ -57,7 +58,7 @@ export async function run(process: NodeJS.Process, sys: d.StencilSystem, logger:
5758
} catch (e) {
5859
if (!shouldIgnoreError(e)) {
5960
config.logger.error(`uncaught cli error: ${e}`);
60-
process.exit(1);
61+
exit(1);
6162
}
6263
}
6364
}

src/cli/run-task.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { taskHelp } from './task-help';
55
import { taskServe } from './task-serve';
66
import { taskTest } from './task-test';
77
import { taskCheckVersion, taskVersion } from './task-version';
8+
import exit from 'exit';
89

910

1011
export async function runTask(process: NodeJS.Process, config: d.Config, flags: d.ConfigFlags) {
@@ -24,7 +25,7 @@ export async function runTask(process: NodeJS.Process, config: d.Config, flags:
2425
break;
2526

2627
case 'docs':
27-
await taskDocs(process, config);
28+
await taskDocs(config);
2829
break;
2930

3031
case 'serve':
@@ -38,7 +39,7 @@ export async function runTask(process: NodeJS.Process, config: d.Config, flags:
3839
default:
3940
config.logger.error(`Invalid stencil command, please see the options below:`);
4041
taskHelp(process, config.logger);
41-
process.exit(1);
42+
exit(1);
4243
}
4344
}
4445
}

src/cli/task-build.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import * as d from '../declarations';
22
import { getLatestCompilerVersion, validateCompilerVersion } from '../sys/node/check-version';
33
import { hasError } from './cli-utils';
4+
import exit from 'exit';
45

56

67
export async function taskBuild(process: NodeJS.Process, config: d.Config, flags: d.ConfigFlags) {
78
const { Compiler } = require('../compiler/index.js');
89

910
const compiler: d.Compiler = new Compiler(config);
1011
if (!compiler.isValid) {
11-
process.exit(1);
12+
exit(1);
1213
}
1314

1415
let devServerStart: Promise<d.DevServer> = null;
@@ -17,7 +18,7 @@ export async function taskBuild(process: NodeJS.Process, config: d.Config, flags
1718
devServerStart = compiler.startDevServer();
1819
} catch (e) {
1920
config.logger.error(e);
20-
process.exit(1);
21+
exit(1);
2122
}
2223
}
2324

@@ -37,7 +38,7 @@ export async function taskBuild(process: NodeJS.Process, config: d.Config, flags
3738
await devServer.close();
3839
}
3940

40-
process.exit(1);
41+
exit(1);
4142
}
4243

4344
if (config.watch || devServerStart) {

src/cli/task-docs.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import * as d from '../declarations';
2+
import exit from 'exit';
23

34

4-
export function taskDocs(process: NodeJS.Process, config: d.Config) {
5+
export function taskDocs(config: d.Config) {
56
const { Compiler } = require('../compiler/index.js');
67

78
const compiler: d.Compiler = new Compiler(config);
89
if (!compiler.isValid) {
9-
process.exit(1);
10+
exit(1);
1011
}
1112

1213
return compiler.docs();

src/cli/task-serve.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import * as d from '../declarations';
22
import { normalizePath } from '../compiler/util';
3+
import exit from 'exit';
34

45

56
export async function taskServe(process: NodeJS.Process, config: d.Config, flags: d.ConfigFlags) {
67
const { Compiler } = require('../compiler/index.js');
78

89
const compiler: d.Compiler = new Compiler(config);
910
if (!compiler.isValid) {
10-
process.exit(1);
11+
exit(1);
1112
}
1213

1314
config.flags.serve = true;
@@ -30,6 +31,6 @@ export async function taskServe(process: NodeJS.Process, config: d.Config, flags
3031
process.once('SIGINT', () => {
3132
compiler.config.sys.destroy();
3233
devServer.close();
33-
process.exit(0);
34+
exit(0);
3435
});
3536
}

src/cli/task-test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as d from '../declarations';
2+
import exit from 'exit';
23

34

45
export async function taskTest(config: d.Config) {
@@ -38,18 +39,18 @@ export async function taskTest(config: d.Config) {
3839

3940
const testing: d.Testing = new Testing(config);
4041
if (!testing.isValid) {
41-
process.exit(1);
42+
exit(1);
4243
}
4344

4445
const passed = await testing.runTests();
4546
await testing.destroy();
4647

4748
if (!passed) {
48-
process.exit(1);
49+
exit(1);
4950
}
5051

5152
} catch (e) {
5253
config.logger.error(e);
53-
process.exit(1);
54+
exit(1);
5455
}
5556
}

src/cli/task-version.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as d from '../declarations';
22
import { printUpdateMessage, requestLatestCompilerVersion } from '../sys/node/check-version';
33
import { lt } from 'semver';
4+
import exit from 'exit';
45

56

67
export function taskVersion(config: d.Config) {
@@ -22,6 +23,6 @@ export async function taskCheckVersion(config: d.Config) {
2223

2324
} catch (e) {
2425
config.logger.error(`unable to load latest compiler version: ${e}`);
25-
process.exit(1);
26+
exit(1);
2627
}
2728
}

0 commit comments

Comments
 (0)