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

Allow backslash #173

Merged
merged 2 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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