mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 09:02:40 +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>
116 lines
3.2 KiB
JavaScript
116 lines
3.2 KiB
JavaScript
// This tests valid options for --experimental-sea-config.
|
|
'use strict';
|
|
|
|
require('../common');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { writeFileSync, existsSync } = require('fs');
|
|
const { spawnSync } = require('child_process');
|
|
const assert = require('assert');
|
|
const { join } = require('path');
|
|
|
|
{
|
|
tmpdir.refresh();
|
|
const config = join(tmpdir.path, 'absolute.json');
|
|
const main = join(tmpdir.path, 'bundle.js');
|
|
const output = join(tmpdir.path, 'output.blob');
|
|
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
|
const configJson = JSON.stringify({
|
|
main,
|
|
output,
|
|
});
|
|
writeFileSync(config, configJson, 'utf8');
|
|
const child = spawnSync(
|
|
process.execPath,
|
|
['--experimental-sea-config', config], {
|
|
cwd: tmpdir.path,
|
|
});
|
|
assert.strictEqual(child.status, 0);
|
|
assert(existsSync(output));
|
|
}
|
|
|
|
{
|
|
tmpdir.refresh();
|
|
const config = join(tmpdir.path, 'relative.json');
|
|
const main = join(tmpdir.path, 'bundle.js');
|
|
const output = join(tmpdir.path, 'output.blob');
|
|
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
|
const configJson = JSON.stringify({
|
|
main: 'bundle.js',
|
|
output: 'output.blob'
|
|
});
|
|
writeFileSync(config, configJson, 'utf8');
|
|
const child = spawnSync(
|
|
process.execPath,
|
|
['--experimental-sea-config', config], {
|
|
cwd: tmpdir.path,
|
|
});
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert(existsSync(output));
|
|
}
|
|
|
|
{
|
|
tmpdir.refresh();
|
|
const config = join(tmpdir.path, 'no-disableExperimentalSEAWarning.json');
|
|
const main = join(tmpdir.path, 'bundle.js');
|
|
const output = join(tmpdir.path, 'output.blob');
|
|
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
|
const configJson = JSON.stringify({
|
|
main: 'bundle.js',
|
|
output: 'output.blob',
|
|
});
|
|
writeFileSync(config, configJson, 'utf8');
|
|
const child = spawnSync(
|
|
process.execPath,
|
|
['--experimental-sea-config', config], {
|
|
cwd: tmpdir.path,
|
|
});
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert(existsSync(output));
|
|
}
|
|
|
|
{
|
|
tmpdir.refresh();
|
|
const config = join(tmpdir.path, 'true-disableExperimentalSEAWarning.json');
|
|
const main = join(tmpdir.path, 'bundle.js');
|
|
const output = join(tmpdir.path, 'output.blob');
|
|
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
|
const configJson = JSON.stringify({
|
|
main: 'bundle.js',
|
|
output: 'output.blob',
|
|
disableExperimentalSEAWarning: true,
|
|
});
|
|
writeFileSync(config, configJson, 'utf8');
|
|
const child = spawnSync(
|
|
process.execPath,
|
|
['--experimental-sea-config', config], {
|
|
cwd: tmpdir.path,
|
|
});
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert(existsSync(output));
|
|
}
|
|
|
|
{
|
|
tmpdir.refresh();
|
|
const config = join(tmpdir.path, 'false-disableExperimentalSEAWarning.json');
|
|
const main = join(tmpdir.path, 'bundle.js');
|
|
const output = join(tmpdir.path, 'output.blob');
|
|
writeFileSync(main, 'console.log("hello")', 'utf-8');
|
|
const configJson = JSON.stringify({
|
|
main: 'bundle.js',
|
|
output: 'output.blob',
|
|
disableExperimentalSEAWarning: false,
|
|
});
|
|
writeFileSync(config, configJson, 'utf8');
|
|
const child = spawnSync(
|
|
process.execPath,
|
|
['--experimental-sea-config', config], {
|
|
cwd: tmpdir.path,
|
|
});
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert(existsSync(output));
|
|
}
|