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

Windows-Friendly Build Script #36

Closed
mjhasbach opened this issue Jan 5, 2016 · 3 comments
Closed

Windows-Friendly Build Script #36

mjhasbach opened this issue Jan 5, 2016 · 3 comments

Comments

@mjhasbach
Copy link
Contributor

In your package.json, you have the following build script:

"build": "rm -rf bin && babel src --out-dir bin && chmod +x ./bin/release.js"

rm and chmod don't work on Windows.

  • For an rm replacement, I recommend rimraf
  • What is the purpose of using chmod on release.js?
@AlexKVal
Copy link
Owner

AlexKVal commented Jan 5, 2016

I'm OK with rimraf.

I have this line in my shell zsh/zshrc.symlink#L56-L57

# npm
export PATH="./node_modules/.bin:$PATH"

It allows me to run locally installed packages straightforward way:

> release patch --run

Without chmod it won't run this way as you see.

Maybe I should add smth like:

"build-win": "rimraf bin && babel src --out-dir bin"

?
Then it would look like: for windows: npm run build-win and for unix* npm run build.
It is the simplest way I see. What do you think ?

@mjhasbach
Copy link
Contributor Author

NPM sets the proper permissions (777) on files in the .bin directory when running npm install. Have a look at this and this. Here's some output from an Ubuntu box:

node@hasba:/www/apps/material-qna/node_modules/.bin$ ls -la
total 8
drwxrwxr-x  2 node node 4096 Dec 19 01:31 .
drwxrwxr-x 45 node node 4096 Dec 19 01:31 ..
lrwxrwxrwx  1 node node   19 Oct 18 20:12 jade -> ../jade/bin/jade.js
lrwxrwxrwx  1 node node   24 Dec 18 20:17 nlp -> ../nlp_compromise/cmd.js
lrwxrwxrwx  1 node node   32 Dec 19 01:31 release -> ../release-script/bin/release.js
lrwxrwxrwx  1 node node   21 Dec 18 20:17 uuid -> ../node-uuid/bin/uuid
lrwxrwxrwx  1 node node   25 Dec 18 20:17 webpack -> ../webpack/bin/webpack.js
node@hasba:/www/apps/material-qna/node_modules/.bin$ ./webpack
webpack 1.12.9
...

As such, I am having trouble understanding the need to chmod during the build process.

Also, $(npm bin):$PATH may be a better solution than ./node_modules/.bin:$PATH for your shell for the reasons mentioned here.

@AlexKVal
Copy link
Owner

AlexKVal commented Jan 7, 2016

Oh.. I didn't know that npm install chmod's all files in bin. Nice 👍 Thank you ❇️
Then I could use it.

As for (npm bin). It doesn't work.
I've tried it.
npm bin runs only once - when new shell starts - and adds only one absolute path to PATH.
So when I change project dir - it doesn't work for me.

E.g. I start new tab in my Terminal with this line export PATH="$(npm bin):$PATH" in shell scripts.

Last login: Thu Jan  7 17:27:50 on ttys005
> alexkval/  
> echo $PATH
/Users/alexkval/node_modules/.bin:/Users/alexkval/.nvm/versions/node/v4.2.3/bin:./bin:/usr/local/bin:/usr/local/sbin:/Users/alexkval/.dotfiles/bin ...etc

then I change project dir:

> z es6-prototype-proj
es6-prototype-proj/ on master
> release
zsh: command not found: release

but as you can see - the script exist:

> l node_modules/release-script/bin/release.js 
-rwxr-xr-x  1 alexkval  staff    16K Jan  4 14:01 node_modules/release-script/bin/release.js

see ? It doesn't work for me 😄

I need relative, not absolute PATH for each project to ./node_modules/.bin.

But when I use export PATH="./node_modules/.bin:$PATH" in shell scripts it works as it should be:

> z es6-prototype-proj
es6-prototype-proj/ on master
> release
Must provide either a version bump type, "preid" or "--only-docs"
Usage: node_modules/.bin/release <version> [--preid <identifier>]
or
... etc

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

No branches or pull requests

2 participants