Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 1bd18e5

Browse files
fix: show message for stopping webpack only when it has been started (#821)
Currently the message `Stopping webpack watch` is printed whenever CLI executes `after-watch` hooks, i.e. when user runs `tns run <platform>` and sends Ctrl+C, the message is shown. However, we have not started any webpack process, so there's nothing to stop. Print the message only when webpack process had been started. Also print it only when `--log trace` is used.
1 parent 70cd58a commit 1bd18e5

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Diff for: lib/after-watch.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ const { stopWebpackCompiler } = require('./compiler');
22
const { removeListener } = require("./utils");
33

44
module.exports = function($logger, $liveSyncService) {
5-
$logger.info("Stopping webpack watch");
6-
stopWebpackCompiler();
5+
stopWebpackCompiler($logger);
76
removeListener($liveSyncService, "liveSyncStopped");
87
removeListener(process, "exit");
98
}

Diff for: lib/before-watch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ module.exports = function ($logger, $liveSyncService, $devicesService, hookArgs)
1010
Object.keys(webpackProcesses).forEach(platform => {
1111
const devices = $devicesService.getDevicesForPlatform(platform);
1212
if (!devices || !devices.length) {
13-
stopWebpackCompiler(platform);
13+
stopWebpackCompiler($logger, platform);
1414
}
1515
});
1616
});
17-
addListener(process, "exit", stopWebpackCompiler);
17+
addListener(process, "exit", () => stopWebpackCompiler($logger));
1818

1919
const platforms = hookArgs.config.platforms;
2020
return Promise.all(platforms.map(platform => {

Diff for: lib/compiler.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $
123123
}
124124
}
125125

126-
exports.stopWebpackCompiler = function stopWebpackCompiler(platform) {
126+
exports.stopWebpackCompiler = function stopWebpackCompiler($logger, platform) {
127127
if (platform) {
128-
stopWebpackForPlatform(platform);
128+
stopWebpackForPlatform($logger, platform);
129129
} else {
130-
Object.keys(webpackProcesses).forEach(platform => stopWebpackForPlatform(platform));
130+
Object.keys(webpackProcesses).forEach(platform => stopWebpackForPlatform($logger, platform));
131131
}
132132
}
133133

@@ -171,9 +171,11 @@ function logSnapshotWarningMessage($logger) {
171171
}
172172
}
173173

174-
function stopWebpackForPlatform(platform) {
174+
function stopWebpackForPlatform($logger, platform) {
175+
$logger.trace(`Stopping webpack watch for platform ${platform}.`);
175176
const webpackProcess = webpackProcesses[platform];
176177
webpackProcess.kill("SIGINT");
178+
177179
delete webpackProcesses[platform];
178180
}
179181

0 commit comments

Comments
 (0)