|  | 
|  | 1 | +import os from 'node:os'; | 
| 1 | 2 | import path from 'node:path'; | 
| 2 | 3 | import { stripVTControlCharacters as stripAnsi } from 'node:util'; | 
| 3 | 4 | import { describe, expect, test } from '@rstest/core'; | 
| @@ -150,33 +151,40 @@ describe('build command', async () => { | 
| 150 | 151 |       runCliSync('build --format cjs', { | 
| 151 | 152 |         cwd: fixturePath, | 
| 152 | 153 |       }), | 
| 153 |  | -    ).toThrowError(/rslib\.config not found in.*cli\/build\/no-config/); | 
|  | 154 | +    ).toThrowError(/rslib\.config not found in.*cli[\\/]build[\\/]no-config/); | 
| 154 | 155 |   }); | 
| 155 | 156 | 
 | 
| 156 | 157 |   test('build options', async () => { | 
| 157 | 158 |     const fixturePath = path.join(__dirname, 'options'); | 
| 158 | 159 |     await fse.remove(path.join(fixturePath, 'dist/ok')); | 
| 159 | 160 | 
 | 
| 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', | 
| 178 | 186 |       }, | 
| 179 |  | -    ); | 
|  | 187 | +    }); | 
| 180 | 188 | 
 | 
| 181 | 189 |     const rslibConfigText = stripAnsi(extractRslibConfig(stdout)); | 
| 182 | 190 |     expect(rslibConfigText).toMatchInlineSnapshot(` | 
|  | 
0 commit comments