Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
fix: missing entrypoint when launched from self-created child process (
Browse files Browse the repository at this point in the history
  • Loading branch information
Luzzifus authored Jun 21, 2023
1 parent e51efbe commit 73a03d1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion prelude/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if (process.env.PKG_EXECPATH === EXECPATH) {
process.argv[1] = DEFAULT_ENTRYPOINT;
}

[, ENTRYPOINT] = process.argv;
[, ENTRYPOINT = DEFAULT_ENTRYPOINT] = process.argv;
delete process.env.PKG_EXECPATH;

// /////////////////////////////////////////////////////////////////
Expand Down
18 changes: 18 additions & 0 deletions test/test-99-#1861/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

'use strict';

const { spawn } = require('child_process');

const { argv } = process;

if (argv.length <= 2) {
console.log('stop');
process.exit();
}

console.log('launch');

const cp = spawn('cmd.exe', ['/C', 'launch.bat'], { shell: true });
cp.stdout.on('data', (output) => console.log(output.toString()));
cp.on('close', process.exit);
3 changes: 3 additions & 0 deletions test/test-99-#1861/launch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
index.exe
exit
28 changes: 28 additions & 0 deletions test/test-99-#1861/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node

'use strict';

const assert = require('assert');
const utils = require('../utils.js');
const path = require('path');

assert(!module.parent);
assert(__dirname === process.cwd());

if (process.platform !== 'win32') {
console.log('Skipping this test on non-windows platform.');
return 0;
}

const input = path.join(__dirname, '/index.js');
const output = path.join(__dirname, '/index.exe');

// build executable
utils.pkg.sync(['--debug', '--target', 'host', '--output', output, input]);

const log = utils.spawn.sync(output, ['launch'], { expect: 0 });

assert(log.includes('launch'));
assert(log.includes('stop'));

utils.vacuum.sync(output);

0 comments on commit 73a03d1

Please sign in to comment.