Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ( error ) {
// If an error occurs, the process can't be ended immediately since
// other workers are likely pending. Optimally, it would end at the
// earliest opportunity (after the current round of workers has had
// the chance to complete), but this is not made directly possible
// through `worker-farm`. Instead, ensure at least that when the
// process does exit, it exits with a non-zero code to reflect the
// fact that an error had occurred.
process.exitCode = 1;
console.error( error );
}
if ( ended && ++complete === files.length ) {
workerFarm.end( worker );
}
} ) )
.on( 'end', () => ended = true )
async function main(): Promise {
const packages = (await fs.readdir(packageDir)).filter(it => !it.includes(".")).sort()
for (const name of packages) {
if (name.includes("electron-forge-maker-") || name.includes("electron-installer-")) {
continue
}
workers(path.join(packageDir, name), (error: Error, hasError: boolean) => {
if (hasError) {
process.exitCode = 1
}
})
}
workerFarm.end(workers)
}
emitter.on(Events.END, () => workerFarm.end(this._workers));
}
emitter.on(RunnerEvents.END, function() {
workerFarm.end(this._workers);
}.bind(this));
},
WorkerFarmRunCompilerStrategy.prototype.close = function() {
workerFarm.end(this.workers);
};
}, function (err) {
log('Tasks finished');
workerFarm.end(workers);
if (err) {
return reject(err);
}
return resolve();
});
});
function endWorkerFarm() {
workerFarm.end(worker);
}
function reduceIt(err, results) {
if (workers) workerFarm.end(workers);
if (err) return callback(err);
var pass = results.reduce(function(pass, result) {
return pass && result;
}, true);
process.stdout.write("\n");
return callback(null, pass);
}
};
function closeFarm () {
workerFarm.end(spawnWorker)
}
workers(opt, (err, output) => {
if (err) {
log.error(err.stack);
farm.end(workers);
callback && callback(err);
return;
}
outs.push(output);
if (outs.length === entries.length) {
log.info(outs.join('\n'));
callback && callback();
farm.end(workers);
}
});
}