Skip to content

Commit

Permalink
fix: if there are spaces in args, then wrap them with quotes (#160)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
FrankFang and antfu committed Jul 18, 2023
1 parent 17d8eeb commit 3ae42dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export function getCommand(
if (!c)
throw new UnsupportedCommand({ agent, command })

return c.replace('{0}', args.join(' ')).trim()
const quote = (arg: string) => (!arg.startsWith('--') && arg.includes(' '))
? JSON.stringify(arg)
: arg

return c.replace('{0}', args.map(quote).join(' ')).trim()
}

export const parseNi = <Runner>((agent, args, ctx) => {
Expand Down

0 comments on commit 3ae42dd

Please sign in to comment.