2023-05-04 15:27:54 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
|
|
const {
|
2024-02-26 15:56:51 +00:00
|
|
|
generateSEA,
|
2023-05-04 15:27:54 +00:00
|
|
|
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');
|
2024-03-20 18:44:14 +00:00
|
|
|
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
2023-05-04 15:27:54 +00:00
|
|
|
const { join } = require('path');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const inputFile = fixtures.path('sea.js');
|
2023-08-21 16:41:53 +00:00
|
|
|
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');
|
2023-05-04 15:27:54 +00:00
|
|
|
|
|
|
|
tmpdir.refresh();
|
|
|
|
|
|
|
|
writeFileSync(requirableFile, `
|
|
|
|
module.exports = {
|
|
|
|
hello: 'world',
|
|
|
|
};
|
|
|
|
`);
|
|
|
|
|
|
|
|
writeFileSync(configFile, `
|
|
|
|
{
|
|
|
|
"main": "sea.js",
|
|
|
|
"output": "sea-prep.blob",
|
|
|
|
"disableExperimentalSEAWarning": true
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
// Copy input to working directory
|
2023-08-21 16:41:53 +00:00
|
|
|
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
2023-11-16 17:26:45 +00:00
|
|
|
spawnSyncAndExitWithoutError(
|
|
|
|
process.execPath,
|
|
|
|
['--experimental-sea-config', 'sea-config.json'],
|
2024-03-20 18:44:14 +00:00
|
|
|
{ cwd: tmpdir.path });
|
2023-05-04 15:27:54 +00:00
|
|
|
|
|
|
|
assert(existsSync(seaPrepBlob));
|
|
|
|
|
2024-02-26 15:56:51 +00:00
|
|
|
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
2023-05-04 15:27:54 +00:00
|
|
|
|
2024-03-20 18:44:14 +00:00
|
|
|
spawnSyncAndAssert(
|
2023-05-04 15:27:54 +00:00
|
|
|
outputFile,
|
|
|
|
[ '-a', '--b=c', 'd' ],
|
2023-11-16 17:26:45 +00:00
|
|
|
{
|
|
|
|
env: {
|
|
|
|
COMMON_DIRECTORY: join(__dirname, '..', 'common'),
|
|
|
|
NODE_DEBUG_NATIVE: 'SEA',
|
|
|
|
...process.env,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
stdout: 'Hello, world! 😊\n'
|
|
|
|
});
|