mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 15:24:18 +00:00
Use node.execPath in runOutOfProcess()
This commit is contained in:
parent
3934413180
commit
61126aef53
@ -61,27 +61,23 @@ function copyFileToTempDir(filename) {
|
||||
return tmpFile.name;
|
||||
}
|
||||
|
||||
function runOutOfProcess(nodeJsFilePath) {
|
||||
var nodeArgs = Array.prototype.slice.call(arguments);
|
||||
function runOutOfProcess() {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
let tmpDir = tmp.dirSync();
|
||||
let content = fs.readFileSync(nodeJsFilePath, 'utf8');
|
||||
let tmpFile = tmp.fileSync({ dir: tmpDir.name });
|
||||
fs.appendFileSync(tmpFile.fd, content, { encoding: 'utf8' });
|
||||
nodeArgs[0] = tmpFile.name;
|
||||
console.log(`runOutOfProcess : ${args.join(' ')}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
console.log('runOutOfProcess command\n node ' + nodeArgs.join(" "));
|
||||
const child = execFile('node', nodeArgs, { cwd: tmpDir.name }, (error, stdout, stderr) => {
|
||||
execFile(process.execPath, args, {cwd: tmpDir.name}, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error("runOutOfProcess failed\n" + error);
|
||||
reject(new Error(`Running ${nodeJsFilePath} failed. error: ${error}`));
|
||||
console.error("runOutOfProcess failed\n", error);
|
||||
reject(new Error(`Running ${modulePath} failed. error: ${error}`));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('runOutOfProcess success\n' + stdout);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user