Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
run-script: always quote args
Browse files Browse the repository at this point in the history
Fixes #7743.
  • Loading branch information
mantoni authored and othiym23 committed Apr 3, 2015
1 parent 91f5cb1 commit 78005eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ function run (pkg, wd, cmd, args, cb) {
function joinArgs (args) {
var joinedArgs = ""
args.forEach(function(arg) {
if (arg.match(/[ '"]/)) arg = '"' + arg.replace(/"/g, '\\"') + '"'
joinedArgs += " " + arg
joinedArgs += ' "' + arg.replace(/"/g, '\\"') + '"'
})
return joinedArgs
}
4 changes: 4 additions & 0 deletions test/tap/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ test('npm run-script with args that contain double quotes', function (t) {
common.npm(['run-script', 'start', '--', 'what"s "up"?'], opts, testOutput.bind(null, t, 'what"s "up"?'))
})

test('npm run-script with args that contain ticks', function (t) {
common.npm(['run-script', 'start', '--', 'what\'s \'up\'?'], opts, testOutput.bind(null, t, 'what\'s \'up\'?'))
})

test('npm run-script with pre script', function (t) {
common.npm(['run-script', 'with-post'], opts, testOutput.bind(null, t, 'main;post'))
})
Expand Down

0 comments on commit 78005eb

Please sign in to comment.