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