diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | lib/moduleEnv.js | 13 | ||||
-rw-r--r-- | package-lock.json | 8 | ||||
-rw-r--r-- | package.json | 2 |
4 files changed, 17 insertions, 8 deletions
@@ -236,7 +236,7 @@ See [rewire-webpack](https://github.com/jhnns/rewire-webpack) CoffeeScript ------------ -Good news to all caffeine-addicts: rewire works also with [Coffee-Script](http://coffeescript.org/). Note that in this case CoffeeScript needs to be listed in your devDependencies. +Good news to all caffeine-addicts: rewire works also with [Coffee-Script](http://coffeescript.org/). Note that in this case you need to install the `coffeescript` package. <br /> diff --git a/lib/moduleEnv.js b/lib/moduleEnv.js index 688401e..599e332 100644 --- a/lib/moduleEnv.js +++ b/lib/moduleEnv.js @@ -133,6 +133,10 @@ function jsExtension(module, filename) { } function coffeeExtension(module, filename) { + if (!coffee) { + throw new Error("Cannot rewire module written in CoffeeScript: Please install 'coffeescript' package first."); + } + var content = stripBOM(fs.readFileSync(filename, "utf8")); restoreExtensions(); @@ -157,9 +161,14 @@ function stripBOM(content) { } try { - coffee = require("coffee-script"); + coffee = require("coffeescript"); } catch (err) { - // We are not able to provide coffee-script support, but that's ok as long as the user doesn't want it. + try { + // Trying to load deprecated package + coffee = require("coffee-script"); + } catch (err) { + // We are not able to provide CoffeeScript support, but that's ok as long as the user doesn't want it. + } } exports.load = load; diff --git a/package-lock.json b/package-lock.json index e5fdf17..f33b507 100644 --- a/package-lock.json +++ b/package-lock.json @@ -176,10 +176,10 @@ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" }, - "coffee-script": { - "version": "1.12.7", - "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.12.7.tgz", - "integrity": "sha512-fLeEhqwymYat/MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG+6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw==", + "coffeescript": { + "version": "2.2.4", + "resolved": "http://registry.npmjs.org/coffeescript/-/coffeescript-2.2.4.tgz", + "integrity": "sha1-QnwDjhehJeUqef2zEGdhdTuFhdI=", "dev": true }, "color-convert": { diff --git a/package.json b/package.json index 436dbf0..c06ad61 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "url": "git://github.com/jhnns/rewire.git" }, "devDependencies": { - "coffee-script": "^1.8.0", + "coffeescript": "^2.1.1", "expect.js": "^0.3.1", "mocha": "^4.0.1" }, |