Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function sendMessage({ config, ctx }: SendMessageDeps, msg: IPCMessage) {
const dir = path.dirname(config.p);
await mkdirp(dir);
const fd = await open(path.resolve(dir, 'helper.log'), 'a');
const p = fork(ctx.binPath, ['_', '--no-interactive'], { stdio: ['ignore', fd, fd, 'ipc'] });
p.send(msg);
p.disconnect();
p.unref();
}
start(): void {
try {
fs.accessSync(this.modulePath, fs.constants.R_OK);
} catch (e) {
debug('Error during access check: %O', e);
throw new IPCError(`Module not accessible: ${this.modulePath}`);
}
const p = fork(this.modulePath, this.args, { stdio: ['ignore', 'ignore', 'ignore', 'ipc'] });
debug('RPC subprocess forked %o', [this.modulePath, ...this.args]);
this.rpc.start(p);
}