Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention platform-independent scripts #3

Merged
merged 1 commit into from
Jul 13, 2015

Conversation

tomek-he-him
Copy link
Contributor

Many npm scripts depend on Unix-only or bash-only features. If you want to make sure your scripts are platform-independent, keep to two rules:

  • Only use cross-shell operators: >, >>, < and | – they work in bash, fish, the windows command prompt and others.
  • Instead of platform-specific tools use node modules with a CLI – for example mkdirp instead of mkdir, cpy instead of cp, mve instead of mv.

@tomek-he-him
Copy link
Contributor Author

By the way, I don’t know of any sensible shell-independent alternative to ;, && and ||. Here’s my idea: tomek-he-him/ideas#1.

What do you think? @mattdesl @npm-scripts @hemanth @stoeffel

@hemanth
Copy link

hemanth commented Jul 13, 2015

'npm test' --and 'echo ✓' --or 'echo Test failed!!!' --then 'npm run build'

Sounds very right to me 👍

@mattdesl
Copy link
Owner

Nice, thanks for the PR! 👍

It would be great to have a separate repo that collects some information on compatibility. e.g. It might list operators/commands that work on unix + windows, and then list some modules that can be used as alternatives (like cp), and tools that can be used like your --or idea, and parallelshell.

mattdesl added a commit that referenced this pull request Jul 13, 2015
@mattdesl mattdesl merged commit cc1cc5a into mattdesl:master Jul 13, 2015
@tomek-he-him
Copy link
Contributor Author

By the way, I don’t know of any sensible shell-independent alternative to ;, && and ||. Here’s my idea: tomek-he-him/ideas#1.

It seems that it’s OK to use && and || after all. I sometimes just take info I find on stackoverflow for granted. But it turns out that this time an answer was wrong: https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true.

This was referenced Jul 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants