diff --git a/.gitignore b/.gitignore index ba2a97b..c4dd4f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +lib/shutdownHandler.js node_modules coverage diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..ba2a97b --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +node_modules +coverage diff --git a/lib/index.js b/lib/index.js index f326858..7373c35 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,12 @@ -// Only require coffeescript if it is not already registered -if (!require.extensions[".coffee"]) require("coffee-script/register"); +try { + module.exports = require("./shutdownHandler"); +} catch(e) { + if(e.message.startsWith("Cannot find module './shutdownHandler'")) { + // Only require coffeescript if it is not already registered + if (!require.extensions[".coffee"]) require("coffee-script/register"); -module.exports = require("./shutdownHandler.coffee"); + module.exports = require("./shutdownHandler.coffee"); + } else { + throw e; + } +} diff --git a/package.json b/package.json index 2a84a6d..fed4f5a 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,15 @@ "homepage": "https://github.com/UberEther/node-shutdown-events", "scripts": { "test": "mocha", - "test-cov": "istanbul cover --config test/istanbul.yml node_modules/mocha/bin/_mocha" + "test-cov": "istanbul cover --config test/istanbul.yml node_modules/mocha/bin/_mocha", + "prepublish": "coffee -o lib -c lib/*.coffee" }, "dependencies": { - "coffee-script": "^1.9.2", "bluebird": "^2.9.13", "debug": "^2.2.0" }, "devDependencies": { + "coffee-script": "^1.9.2", "mocha": "^2.3.0", "chai": "^3.2.0", "rewire": "^2.3.4",