mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
c714cda9a7
PR-URL: https://github.com/nodejs/node/pull/52132 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const {
|
|
generateSEA,
|
|
skipIfSingleExecutableIsNotSupported,
|
|
} = require('../common/sea');
|
|
|
|
skipIfSingleExecutableIsNotSupported();
|
|
|
|
// This tests the creation of a single executable application which has the
|
|
// experimental SEA warning disabled.
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
|
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
|
const { join } = require('path');
|
|
const assert = require('assert');
|
|
|
|
const inputFile = fixtures.path('sea.js');
|
|
const requirableFile = tmpdir.resolve('requirable.js');
|
|
const configFile = tmpdir.resolve('sea-config.json');
|
|
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
|
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
|
|
|
tmpdir.refresh();
|
|
|
|
writeFileSync(requirableFile, `
|
|
module.exports = {
|
|
hello: 'world',
|
|
};
|
|
`);
|
|
|
|
writeFileSync(configFile, `
|
|
{
|
|
"main": "sea.js",
|
|
"output": "sea-prep.blob",
|
|
"disableExperimentalSEAWarning": true
|
|
}
|
|
`);
|
|
|
|
// Copy input to working directory
|
|
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
|
spawnSyncAndExitWithoutError(
|
|
process.execPath,
|
|
['--experimental-sea-config', 'sea-config.json'],
|
|
{ cwd: tmpdir.path });
|
|
|
|
assert(existsSync(seaPrepBlob));
|
|
|
|
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
|
|
|
spawnSyncAndAssert(
|
|
outputFile,
|
|
[ '-a', '--b=c', 'd' ],
|
|
{
|
|
env: {
|
|
COMMON_DIRECTORY: join(__dirname, '..', 'common'),
|
|
NODE_DEBUG_NATIVE: 'SEA',
|
|
...process.env,
|
|
}
|
|
},
|
|
{
|
|
stdout: 'Hello, world! 😊\n'
|
|
});
|