Q: Is it possible to change the the context in which npm runs scripts?
What I want to is the following:
"scripts": {
"test": "gulp mocha",
"pre-install": "./deps/2.7/cpython/configure --prefix=$(pwd)/build --exec-prefix=$(pwd)/build && make -C deps/2.7/cpython && make -C deps/2.7/cpython install",
"install": "node-gyp rebuild"
},
Obviously cd deps/2.7/cpython/ && ./configure
would work on UNIX-like systems but not on windows.
Why: The root of the problem is, that the configure
command of the python repo outputs files into the directory where it is called. The files however are build relevant for make
and make install
which look for the files in the directory of the repo.
In this case I can't change the Makefile
since the build process of Python is understandably complex.
Alternative: The alternative is probably to write some install.js
and use node's OS independent API and some child_process.exec()
, which I am probably gonna do. However, not leaving npm would be really nice.