Skip to content

Commit

Permalink
fixup! fixup! fixup! src: support snapshot in single executable appli…
Browse files Browse the repository at this point in the history
…cations
  • Loading branch information
joyeecheung committed Jul 20, 2023
1 parent a5bc23d commit c481fd5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/node_sea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ bool IsSingleExecutable() {
}

void IsExperimentalSeaWarningNeeded(const FunctionCallbackInfo<Value>& args) {
bool is_building_sea =
!per_process::cli_options->experimental_sea_config.empty();
if (is_building_sea) {
args.GetReturnValue().Set(true);
return;
}

if (!IsSingleExecutable()) {
args.GetReturnValue().Set(false);
return;
Expand Down
14 changes: 10 additions & 4 deletions test/sequential/test-single-executable-application-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ skipIfSingleExecutableIsNotSupported();

const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { execFileSync, spawnSync } = require('child_process');
const { spawnSync } = require('child_process');
const { join } = require('path');
const assert = require('assert');

Expand Down Expand Up @@ -66,18 +66,24 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' :
}
`);

execFileSync(
let child = spawnSync(
process.execPath,
['--experimental-sea-config', 'sea-config.json'],
{
cwd: tmpdir.path
});
assert.match(
child.stderr.toString(),
/Single executable application is an experimental feature/);

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);

const out = execFileSync(outputFile);
assert.strictEqual(out.toString().trim(), 'Hello from snapshot');
child = spawnSync(outputFile);
assert.strictEqual(child.stdout.toString().trim(), 'Hello from snapshot');
assert.doesNotMatch(
child.stderr.toString(),
/Single executable application is an experimental feature/);
}

0 comments on commit c481fd5

Please sign in to comment.