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

fix: show message for stopping webpack only when it has been started #821

Merged
merged 1 commit into from
Mar 11, 2019
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
3 changes: 1 addition & 2 deletions lib/after-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const { stopWebpackCompiler } = require('./compiler');
const { removeListener } = require("./utils");

module.exports = function($logger, $liveSyncService) {
$logger.info("Stopping webpack watch");
stopWebpackCompiler();
stopWebpackCompiler($logger);
removeListener($liveSyncService, "liveSyncStopped");
removeListener(process, "exit");
}
4 changes: 2 additions & 2 deletions lib/before-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ module.exports = function ($logger, $liveSyncService, $devicesService, hookArgs)
Object.keys(webpackProcesses).forEach(platform => {
const devices = $devicesService.getDevicesForPlatform(platform);
if (!devices || !devices.length) {
stopWebpackCompiler(platform);
stopWebpackCompiler($logger, platform);
}
});
});
addListener(process, "exit", stopWebpackCompiler);
addListener(process, "exit", () => stopWebpackCompiler($logger));

const platforms = hookArgs.config.platforms;
return Promise.all(platforms.map(platform => {
Expand Down
10 changes: 6 additions & 4 deletions lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $
}
}

exports.stopWebpackCompiler = function stopWebpackCompiler(platform) {
exports.stopWebpackCompiler = function stopWebpackCompiler($logger, platform) {
if (platform) {
stopWebpackForPlatform(platform);
stopWebpackForPlatform($logger, platform);
} else {
Object.keys(webpackProcesses).forEach(platform => stopWebpackForPlatform(platform));
Object.keys(webpackProcesses).forEach(platform => stopWebpackForPlatform($logger, platform));
}
}

Expand Down Expand Up @@ -171,9 +171,11 @@ function logSnapshotWarningMessage($logger) {
}
}

function stopWebpackForPlatform(platform) {
function stopWebpackForPlatform($logger, platform) {
$logger.trace(`Stopping webpack watch for platform ${platform}.`);
const webpackProcess = webpackProcesses[platform];
webpackProcess.kill("SIGINT");

delete webpackProcesses[platform];
}