Skip to content

Commit

Permalink
feat(launcher): normalize quoted paths
Browse files Browse the repository at this point in the history
Closes #491
  • Loading branch information
vojtajina committed Jul 4, 2013
1 parent 42bf787 commit f2155e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/launchers/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ var BaseBrowser = function(id, emitter, captureTimeout, retryLimit) {


this._execCommand = function(cmd, args) {
// normalize the cmd, remove quotes (spawn does not like them)
if (cmd.charAt(0) === cmd.charAt(cmd.length - 1) && '\'`"'.indexOf(cmd.charAt(0)) !== -1) {
cmd = cmd.substring(1, cmd.length - 1);
log.warn('The path should not be quoted.\n Normalized the path to %s', cmd);
}

log.debug(cmd + ' ' + args.join(' '));
self._process = spawn(cmd, args);

Expand Down
16 changes: 16 additions & 0 deletions test/unit/launchers/Base.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ describe 'launchers Base', ->
expect(spawnProcess.kill).to.not.have.been.called


it 'should remove quotes from the cmd', ->
browser = new m.BaseBrowser 123

browser.DEFAULT_CMD = darwin: '"/bin/brow ser"'
browser.start '/url'
expect(mockSpawn).to.have.been.calledWith '/bin/brow ser', ['/url?id=123']

browser.DEFAULT_CMD = darwin: '\'bin/brow ser\''
browser.start '/url'
expect(mockSpawn).to.have.been.calledWith '/bin/brow ser', ['/url?id=123']

browser.DEFAULT_CMD = darwin: '`bin/brow ser`'
browser.start '/url'
expect(mockSpawn).to.have.been.calledWith '/bin/brow ser', ['/url?id=123']


describe 'kill', ->
it 'should just fire done if already killed', (done) ->
browser = new m.BaseBrowser 123, new events.EventEmitter, 0, 1 # disable retry
Expand Down

0 comments on commit f2155e0

Please sign in to comment.