Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ewald <mail@johannesewald.de>2018-04-10 02:03:40 +0300
committerGitHub <noreply@github.com>2018-04-10 02:03:40 +0300
commit999dd1d7aeb64bb82ac3346ab98b7fd0c073b591 (patch)
tree6fb5d310a550332f1213ed00856eef02a334b6e8
parente9437cc4fc137e3024163c59349866d1f30235ac (diff)
parentd124260bf69269a8903f84449bf60da2ea69bd9d (diff)
Merge pull request #134 from jhnns/pr/origin/127
Use 'coffeescript' package
-rw-r--r--README.md4
-rw-r--r--lib/moduleEnv.js13
-rw-r--r--package-lock.json8
-rw-r--r--package.json2
4 files changed, 18 insertions, 9 deletions
diff --git a/README.md b/README.md
index c8a589d..0c2a591 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ rewire
[![](https://img.shields.io/npm/v/rewire.svg)](https://www.npmjs.com/package/rewire)
[![](https://img.shields.io/npm/dm/rewire.svg)](https://www.npmjs.com/package/rewire)
[![Dependency Status](https://david-dm.org/jhnns/rewire.svg)](https://david-dm.org/jhnns/rewire)
-[![Build Status](https://travis-ci.org/jhnns/rewire.svg?branch=master)](https://travis-ci.org/rewire/jhnns)
+[![Build Status](https://travis-ci.org/jhnns/rewire.svg?branch=master)](https://travis-ci.org/jhnns/rewire)
[![Coverage Status](https://img.shields.io/coveralls/jhnns/rewire.svg)](https://coveralls.io/r/jhnns/rewire?branch=master)
rewire adds a special setter and getter to modules so you can modify their behaviour for better unit testing. You may
@@ -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"
},