Skip to content

Commit

Permalink
fix: Introduce cross-spawn for cross platform commands (#175)
Browse files Browse the repository at this point in the history
This PR introduces cross platform spawning of commands. Will close #174. 

The problem is Windows users need to use the `exec` command like this: 
```
$ percy exec -- cypress.cmd run
``` 

If they don't, we can't spawn their original test command. What's happening is nodes `spawn` ignores windows `PATHEXT` which is kinda like `$PATH` & that means `spawn` only works on Windows for `.exe` files. See: 
- nodejs/node-v0.x-archive#2318
- bcoe/awesome-cross-platform-nodejs#26

Tested here: https://github.com/percy/example-percy-cypress/compare/rd/test-cross-platform

The first commit uses `cross_spawn` and successfully starts Cypress. The second commit uses `0.4.0` of agent and fails to start Cypress.
  • Loading branch information
Robdel12 committed Apr 30, 2019
1 parent dfa9746 commit f9bc817
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
50 changes: 20 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -29,6 +29,7 @@
"body-parser": "^1.18.3",
"colors": "^1.3.2",
"cors": "^2.8.4",
"cross-spawn": "^6.0.5",
"express": "^4.16.3",
"globby": "^9.2.0",
"js-yaml": "^3.13.1",
Expand All @@ -52,6 +53,7 @@
"@types/chai": "^4.1.4",
"@types/chai-http": "^3.0.5",
"@types/cors": "^2.8.4",
"@types/cross-spawn": "^6.0.0",
"@types/http-server": "^0.10.0",
"@types/mocha": "^5.2.5",
"@types/nock": "^9.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/exec.ts
@@ -1,5 +1,5 @@
import {flags} from '@oclif/command'
import {spawn} from 'child_process'
import * as spawn from 'cross-spawn'
import Constants from '../services/constants'
import PercyCommand from './percy-command'

Expand Down

0 comments on commit f9bc817

Please sign in to comment.