diff --git a/.travis.yml b/.travis.yml index 2ca91f2..55e2588 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js node_js: - - "0.10" - - "0.8" \ No newline at end of file + - "4" + - "6" + - "8" \ No newline at end of file diff --git a/index.js b/index.js index 9f22e10..1630942 100644 --- a/index.js +++ b/index.js @@ -130,15 +130,15 @@ function writeShim_ (from, to, prog, args, cb) { var sh = "#!/bin/sh\n" - if (shLongProg) { - sh = sh - + "basedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")\n" - + "\n" - + "case `uname` in\n" - + " *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;\n" - + "esac\n" - + "\n" + sh = sh + + "basedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")\n" + + "\n" + + "case `uname` in\n" + + " *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;\n" + + "esac\n" + + "\n" + if (shLongProg) { sh = sh + "if [ -x "+shLongProg+" ]; then\n" + " " + shLongProg + " " + args + " " + shTarget + " \"$@\"\n" @@ -149,7 +149,8 @@ function writeShim_ (from, to, prog, args, cb) { + "fi\n" + "exit $ret\n" } else { - sh = shProg + " " + args + " " + shTarget + " \"$@\"\n" + sh = sh + + shProg + " " + args + " " + shTarget + " \"$@\"\n" + "exit $?\n" } diff --git a/test/basic.js b/test/basic.js index 0982315..9b0d4d0 100755 --- a/test/basic.js +++ b/test/basic.js @@ -13,7 +13,14 @@ test('no shebang', function (t) { if (er) throw er t.equal(fs.readFileSync(to, 'utf8'), - "\"$basedir/from.exe\" \"$@\"\nexit $?\n") + "#!/bin/sh"+ + "\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")"+ + "\n"+ + "\ncase `uname` in"+ + "\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;"+ + "\nesac"+ + "\n"+ + "\n\"$basedir/from.exe\" \"$@\"\nexit $?\n") t.equal(fs.readFileSync(to + '.cmd', 'utf8'), "@\"%~dp0\\from.exe\" %*\r\n") t.end()