2021-03-14 08:42:46 +01:00
|
|
|
import { fork } from 'child_process';
|
2019-12-15 12:07:29 +01:00
|
|
|
|
2021-03-14 08:42:46 +01:00
|
|
|
export function prepareEnvironment(rootFolder: string, folderName: string) {}
|
2019-12-15 12:07:29 +01:00
|
|
|
|
2021-03-14 08:42:46 +01:00
|
|
|
export function spawnRegistry(verdaccioPath: string, args: string[], childOptions) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let _childOptions = { silent: true, ...childOptions };
|
2019-12-15 12:07:29 +01:00
|
|
|
|
2021-03-14 08:42:46 +01:00
|
|
|
const childFork = fork(verdaccioPath, args, _childOptions);
|
2019-12-15 12:07:29 +01:00
|
|
|
|
2021-04-03 13:13:31 +02:00
|
|
|
childFork.on('message', (msg: {verdaccio_started: boolean}) => {
|
|
|
|
if (msg.verdaccio_started) {
|
2021-03-14 08:42:46 +01:00
|
|
|
resolve(childFork);
|
|
|
|
}
|
|
|
|
});
|
2019-12-15 12:07:29 +01:00
|
|
|
|
2021-03-14 08:42:46 +01:00
|
|
|
childFork.on('error', (err) => reject([err]));
|
|
|
|
childFork.on('disconnect', (err) => reject([err]));
|
|
|
|
childFork.on('exit', (err) => reject([err]));
|
|
|
|
});
|
2019-12-15 12:07:29 +01:00
|
|
|
}
|