Skip to content

Commit

Permalink
fix(windows): support backslash in cli arguments (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan committed Nov 23, 2021
1 parent 555c535 commit 8c8f19f
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 8 deletions.
167 changes: 160 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -61,6 +61,7 @@
"resolve": "^1.20.0",
"rollup-plugin-dts": "^3.0.2",
"rollup-plugin-hashbang": "^2.2.2",
"slash": "^4.0.0",
"string-argv": "^0.3.1",
"strip-json-comments": "^3.1.1",
"svelte": "3.37.0",
Expand Down
3 changes: 2 additions & 1 deletion src/cli-main.ts
Expand Up @@ -2,6 +2,7 @@ import { readFileSync } from 'fs'
import { join } from 'path'
import { cac } from 'cac'
import flat from 'flat'
import slash from 'slash'
import { Format, Options } from '.'

function ensureArray(input: string): string[] {
Expand Down Expand Up @@ -88,7 +89,7 @@ export async function main(options: Options = {}) {
...flags,
})
if (files.length > 0) {
options.entryPoints = files
options.entryPoints = files.map(slash)
}
if (flags.format) {
const format = ensureArray(flags.format) as Format[]
Expand Down
15 changes: 15 additions & 0 deletions test/index.test.ts
Expand Up @@ -1080,3 +1080,18 @@ test('multiple entry with the same base name', async () => {
]
`)
})

test('backslash in entry', async () => {
const { outFiles } = await run(
getTestName(),
{ 'src/input.ts': `export const foo = 1` },
{
entry: ['src\\input.ts'],
}
)
expect(outFiles).toMatchInlineSnapshot(`
Array [
"input.js",
]
`)
})

1 comment on commit 8c8f19f

@vercel
Copy link

@vercel vercel bot commented on 8c8f19f Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.