dimanche 19 avril 2015

why the command script generated for my npm package is different than other package?

I published a npm package myself: makeTimeTable


I installed it happily in cygwin:



npm install -g maketimetable


But when I try to run the command line, an error is thrown:



/node_modules/maketimetable/cli.js: No such file or directory


Finally I figure out that the command script file(C:\Users\xxx\AppData\Roaming\npm\maketimetable) generated when installing my package is different than other global command line tools I installed, below is mine:



"$basedir/node_modules/maketimetable/cli.js" "$@"
exit $?


other global command line tools' script is like this:



#!/bin/sh
basedir=`dirname "$0"`

case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/node_modules/eslint/bin/eslint.js" "$@"
ret=$?
else
node "$basedir/node_modules/eslint/bin/eslint.js" "$@"
ret=$?
fi
exit $ret


So in other tools' script, it will distinguish whether I'm using cygwin, it will treat the path and directory a little differently. But why my package's script is different than those? How can I make npm to generate the same kind of script for my package?


Aucun commentaire:

Enregistrer un commentaire