Skip to content

Commit f342082

Browse files
committed
thank u win32.
1 parent 6a803af commit f342082

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

packages/core/src/cli/initConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const applyCliOptions = (
117117
if (externals.length > 0) output.externals = externals;
118118
if (options.distPath) {
119119
output.distPath = {
120-
...(output.distPath ?? {}),
120+
...(typeof output.distPath === 'object' ? output.distPath : {}),
121121
root: options.distPath,
122122
};
123123
}

tests/integration/cli/build/build.test.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'node:os';
12
import path from 'node:path';
23
import { stripVTControlCharacters as stripAnsi } from 'node:util';
34
import { describe, expect, test } from '@rstest/core';
@@ -150,33 +151,40 @@ describe('build command', async () => {
150151
runCliSync('build --format cjs', {
151152
cwd: fixturePath,
152153
}),
153-
).toThrowError(/rslib\.config not found in.*cli\/build\/no-config/);
154+
).toThrowError(/rslib\.config not found in.*cli[\\/]build[\\/]no-config/);
154155
});
155156

156157
test('build options', async () => {
157158
const fixturePath = path.join(__dirname, 'options');
158159
await fse.remove(path.join(fixturePath, 'dist/ok'));
159160

160-
const stdout = runCliSync(
161-
'build ' +
162-
'--entry="./src/*" ' +
163-
'--dist-path=dist/ok ' +
164-
'--no-bundle ' +
165-
'--format=esm ' +
166-
`--syntax='["node 14", "Chrome 103"]' ` +
167-
'--target=web ' +
168-
'--dts=true ' +
169-
'--externals=./bar ' +
170-
'--minify=false ' +
171-
'--auto-extension=false',
172-
{
173-
cwd: fixturePath,
174-
env: {
175-
...process.env,
176-
DEBUG: 'rslib',
177-
},
161+
const syntaxTargetsJson = JSON.stringify(['node 14', 'Chrome 103']);
162+
const syntaxOption =
163+
os.platform() === 'win32'
164+
? `--syntax="${syntaxTargetsJson.replace(/"/g, '\\"')}"`
165+
: `--syntax='${syntaxTargetsJson}'`;
166+
167+
const command = [
168+
'build',
169+
'--entry="./src/*"',
170+
'--dist-path=dist/ok',
171+
'--no-bundle',
172+
'--format=esm',
173+
syntaxOption,
174+
'--target=web',
175+
'--dts=true',
176+
'--externals=./bar',
177+
'--minify=false',
178+
'--auto-extension=false',
179+
].join(' ');
180+
181+
const stdout = runCliSync(command, {
182+
cwd: fixturePath,
183+
env: {
184+
...process.env,
185+
DEBUG: 'rslib',
178186
},
179-
);
187+
});
180188

181189
const rslibConfigText = stripAnsi(extractRslibConfig(stdout));
182190
expect(rslibConfigText).toMatchInlineSnapshot(`

0 commit comments

Comments
 (0)