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 )
it('should call generate workers and return farm promise', () => {
jest.spyOn(console, 'log').mockImplementation(() => {});
promisify.mockReturnValueOnce(jest.fn());
const returnPromise = run('testConfig.js', { colors: false }, jest.fn());
expect(workerFarm.mock.calls[0][0]).toEqual({ maxRetries: 0 });
expect(returnPromise).toBe(Bluebird);
expect(promisify).toHaveBeenCalledTimes(1);
expect(error).toHaveBeenCalledTimes(1);
expect(then).toHaveBeenCalledTimes(2);
expect(Bluebird.finally).toHaveBeenCalledTimes(1);
expect(asCallback).toHaveBeenCalledTimes(1);
});
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)
}