2023-05-23 19:37:29 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
|
|
const {
|
|
|
|
injectAndCodeSign,
|
|
|
|
skipIfSingleExecutableIsNotSupported,
|
|
|
|
} = require('../common/sea');
|
|
|
|
|
|
|
|
skipIfSingleExecutableIsNotSupported();
|
|
|
|
|
|
|
|
// This tests the creation of a single executable application with an empty
|
|
|
|
// script.
|
|
|
|
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
2023-11-16 18:26:45 +01:00
|
|
|
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
|
2023-05-23 19:37:29 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
|
2023-08-22 01:41:53 +09:00
|
|
|
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-23 19:37:29 +02:00
|
|
|
|
|
|
|
tmpdir.refresh();
|
|
|
|
|
2023-08-22 01:41:53 +09:00
|
|
|
writeFileSync(tmpdir.resolve('empty.js'), '', 'utf-8');
|
2023-05-23 19:37:29 +02:00
|
|
|
writeFileSync(configFile, `
|
|
|
|
{
|
|
|
|
"main": "empty.js",
|
|
|
|
"output": "sea-prep.blob"
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
2023-11-16 18:26:45 +01:00
|
|
|
spawnSyncAndExitWithoutError(
|
|
|
|
process.execPath,
|
|
|
|
['--experimental-sea-config', 'sea-config.json'],
|
|
|
|
{ cwd: tmpdir.path });
|
2023-05-23 19:37:29 +02:00
|
|
|
|
|
|
|
assert(existsSync(seaPrepBlob));
|
|
|
|
|
|
|
|
copyFileSync(process.execPath, outputFile);
|
|
|
|
injectAndCodeSign(outputFile, seaPrepBlob);
|
|
|
|
|
2023-11-16 18:26:45 +01:00
|
|
|
spawnSyncAndExitWithoutError(
|
|
|
|
outputFile,
|
|
|
|
{
|
|
|
|
env: {
|
|
|
|
NODE_DEBUG_NATIVE: 'SEA',
|
|
|
|
...process.env,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{});
|