|
1 | 1 | const { getWebpackProcesses, runWebpackCompiler, stopWebpackCompiler } = require("./compiler");
|
| 2 | +let isAttachedOnEvents = false; |
2 | 3 |
|
3 | 4 | module.exports = function ($logger, $liveSyncService, $devicesService, hookArgs) {
|
4 | 5 | if (hookArgs.config) {
|
5 | 6 | const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions;
|
6 | 7 | if (appFilesUpdaterOptions.bundle) {
|
7 |
| - $liveSyncService.on("liveSyncStopped", data => { |
8 |
| - const webpackProcesses = getWebpackProcesses(); |
9 |
| - Object.keys(webpackProcesses).forEach(platform => { |
10 |
| - const devices = $devicesService.getDevicesForPlatform(platform); |
11 |
| - if (!devices || !devices.length) { |
12 |
| - stopWebpackCompiler(platform); |
13 |
| - } |
| 8 | + if (!isAttachedOnEvents) { |
| 9 | + $liveSyncService.on("liveSyncStopped", data => { |
| 10 | + const webpackProcesses = getWebpackProcesses(); |
| 11 | + Object.keys(webpackProcesses).forEach(platform => { |
| 12 | + const devices = $devicesService.getDevicesForPlatform(platform); |
| 13 | + if (!devices || !devices.length) { |
| 14 | + stopWebpackCompiler(platform); |
| 15 | + } |
| 16 | + }); |
14 | 17 | });
|
15 |
| - }); |
16 | 18 |
|
17 |
| - process.on("exit", () => { |
18 |
| - stopWebpackCompiler(); |
19 |
| - }); |
| 19 | + process.on("exit", () => { |
| 20 | + stopWebpackCompiler(); |
| 21 | + }); |
| 22 | + |
| 23 | + isAttachedOnEvents = true; |
| 24 | + } |
20 | 25 |
|
21 | 26 | const platforms = hookArgs.config.platforms;
|
22 | 27 | return Promise.all(platforms.map(platform => {
|
|
0 commit comments