Files
youle_cocos/.pnpm-store/v11/projects/f47659282495706053836086ad375b3e/scripts/test/cli-entry.test.mjs
T
2026-09-05 00:12:11 +08:00

23 lines
912 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { dirname, join } from 'node:path';
const scriptsDir = join(dirname(fileURLToPath(import.meta.url)), '..');
const CLI = [
'setup-links.mjs', 'new-game.mjs', 'check-cocos-version.mjs', 'bump-cocos.mjs',
'check-skin.mjs', 'build-game.mjs',
];
for (const name of CLI) {
test(`${name} 被动态 import 时不崩溃(argv[1] undefined)`, () => {
const url = pathToFileURL(join(scriptsDir, name)).href;
const r = spawnSync(process.execPath,
['--input-type=module', '-e', `import(${JSON.stringify(url)}).then(()=>process.exit(0))`],
{ encoding: 'utf8' });
assert.equal(r.status, 0, `stderr: ${r.stderr}`);
assert.ok(!/TypeError/.test(r.stderr), `不应出现 TypeError: ${r.stderr}`);
});
}