[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
fix: allow backslash (#173)
Browse files Browse the repository at this point in the history
* add backslash test

* allow escaped backslash through
  • Loading branch information
greggman authored and Kent C. Dodds committed Mar 9, 2018
1 parent 5204dd6 commit 450dae9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ it(`should propagate kill signals`, () => {
expect(crossSpawnMock.__mock.spawned.kill).toHaveBeenCalledWith('SIGBREAK')
})

it(`should keep backslashes`, () => {
isWindowsMock.__mock.returnValue = true
crossEnv(['echo', '\\\\\\\\someshare\\\\somefolder'])
expect(crossSpawnMock.spawn).toHaveBeenCalledWith(
'echo',
['\\\\someshare\\somefolder'],
{
stdio: 'inherit',
env: Object.assign({}, process.env),
},
)
isWindowsMock.__mock.reset()
})


function testEnvSetting(expected, ...envSettings) {
if (expected.APPDATA === 2) {
// kill the APPDATA to test both is undefined
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ function parseCommand(args) {
// match "\'" or "'"
// or match "\" if followed by [$"\] (lookahead)
.map(a => {
const re = /(\\)?'|([\\])(?=[$"\\])/g
const re = /\\\\|(\\)?'|([\\])(?=[$"\\])/g
// Eliminate all matches except for "\'" => "'"
return a.replace(re, m => {
if (m === "\\\\") return "\\"
if (m === "\\'") return "'"
return ''
})
Expand Down

0 comments on commit 450dae9

Please sign in to comment.