mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 14:25:18 +00:00

Refs: https://github.com/nodejs/single-executable/discussions/60 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/47588 Fixes: https://github.com/nodejs/node/issues/47741 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Tierney Cyren <hello@bnb.im> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const {
|
|
injectAndCodeSign,
|
|
skipIfSingleExecutableIsNotSupported,
|
|
} = require('../common/sea');
|
|
|
|
skipIfSingleExecutableIsNotSupported();
|
|
|
|
// This tests the creation of a single executable application.
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
|
const { execFileSync } = require('child_process');
|
|
const { join } = require('path');
|
|
const { strictEqual } = require('assert');
|
|
const assert = require('assert');
|
|
|
|
const inputFile = fixtures.path('sea.js');
|
|
const requirableFile = join(tmpdir.path, 'requirable.js');
|
|
const configFile = join(tmpdir.path, 'sea-config.json');
|
|
const seaPrepBlob = join(tmpdir.path, 'sea-prep.blob');
|
|
const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
|
|
|
tmpdir.refresh();
|
|
|
|
writeFileSync(requirableFile, `
|
|
module.exports = {
|
|
hello: 'world',
|
|
};
|
|
`);
|
|
|
|
writeFileSync(configFile, `
|
|
{
|
|
"main": "sea.js",
|
|
"output": "sea-prep.blob",
|
|
"disableExperimentalSEAWarning": false
|
|
}
|
|
`);
|
|
|
|
// Copy input to working directory
|
|
copyFileSync(inputFile, join(tmpdir.path, 'sea.js'));
|
|
execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], {
|
|
cwd: tmpdir.path
|
|
});
|
|
|
|
assert(existsSync(seaPrepBlob));
|
|
|
|
copyFileSync(process.execPath, outputFile);
|
|
injectAndCodeSign(outputFile, seaPrepBlob);
|
|
|
|
const singleExecutableApplicationOutput = execFileSync(
|
|
outputFile,
|
|
[ '-a', '--b=c', 'd' ],
|
|
{ env: { COMMON_DIRECTORY: join(__dirname, '..', 'common') } });
|
|
strictEqual(singleExecutableApplicationOutput.toString(), 'Hello, world! 😊\n');
|