Skip to content

Commit 5930569

Browse files
committed
test: simplify execCli command handling
1 parent aa92228 commit 5930569

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/rstack/test/cli/specify-config/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getDistFiles, getFileContent, test } from '#test-helpers';
55
test('should build with rstack --config', async ({ cwd, execCli, expect }) => {
66
await rm(path.join(cwd, 'dist'), { recursive: true, force: true });
77

8-
execCli(['--config', './custom.config.ts', 'build']);
8+
execCli('build --config ./custom.config.ts');
99

1010
const files = await getDistFiles(path.join(cwd, 'dist'));
1111
const output = getFileContent(files, 'static/js/index.js');

packages/rstack/test/config/define-app/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test('should build app with define.app config', async ({ cwd, execCli, expect })
99
await rm(distPath, { recursive: true, force: true });
1010

1111
try {
12-
execCli(['build']);
12+
execCli('build');
1313

1414
const files = await getDistFiles(distPath);
1515
const output = getFileContent(files, 'static/js/index.js');

packages/rstack/test/config/define-lib/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('should build lib with define.lib config', async ({ cwd, execCli, expect })
88
const distPath = path.join(cwd, 'dist');
99
await rm(distPath, { recursive: true, force: true });
1010

11-
execCli(['lib']);
11+
execCli('lib');
1212

1313
const files = await getDistFiles(distPath);
1414
const output = getFileContent(files, 'index.js');

packages/rstack/test/helpers/cli.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { type ExecFileSyncOptions, execFileSync } from 'node:child_process';
1+
import { type ExecSyncOptions, execSync } from 'node:child_process';
22
import path from 'node:path';
33

44
const RSTACK_BIN_PATH = path.join(import.meta.dirname, '../../bin/rs.js');
55

6-
export type ExecCli = (args: string[], options?: ExecFileSyncOptions) => string;
6+
export type ExecCli = (command: string, options?: ExecSyncOptions) => string;
77

8-
export const execCli = (args: string[], options: ExecFileSyncOptions = {}): string => {
9-
const output = execFileSync(process.execPath, [RSTACK_BIN_PATH, ...args], {
8+
export const execCli: ExecCli = (command, options = {}) => {
9+
const output = execSync(`${RSTACK_BIN_PATH} ${command}`, {
1010
...options,
1111
env: {
1212
...process.env,

packages/rstack/test/helpers/cliTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export const test: CliTest = baseTest.extend<CliTestFixtures>({
2020
await use(path.dirname(testPath));
2121
},
2222
execCli: async ({ cwd }, use) => {
23-
const execCli: ExecCli = (args, options = {}) =>
24-
baseExecCli(args, { ...options, cwd: options.cwd ?? cwd });
23+
const execCli: ExecCli = (command, options = {}) =>
24+
baseExecCli(command, { ...options, cwd: options.cwd ?? cwd });
2525

2626
await use(execCli);
2727
},

0 commit comments

Comments
 (0)