Skip to content

Instantly share code, notes, and snippets.

@dgieselaar
Last active August 29, 2015 14:07
Show Gist options
  • Save dgieselaar/4ab230076453f931e8ae to your computer and use it in GitHub Desktop.
Save dgieselaar/4ab230076453f931e8ae to your computer and use it in GitHub Desktop.
If you run `npm install` on Windows, the build script creates .cmd wrappers for the package scripts in `node_modules/.bin`. This is to ensure commands like "bower install" works on Windows in your `scripts`. However, if you run `npm install` on a Unix machine, those .cmd files won't be added, which causes your scripts to fail on a Windows machin…
for f in $(find './node_modules/.bin' -maxdepth 1 ! -name "*.*"); do
name=$(basename $f);
cp cmdwrap.tpl "$f.cmd";
sed -i "s,PACKAGE_NAME,$name,g" $f.cmd;
done
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\PACKAGE_NAME\bin\PACKAGE_NAME" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\PACKAGE_NAME\bin\PACKAGE_NAME" %*
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment