Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88f6024

Browse files
committed
Try to require coffee-script on start-up
1 parent 52c3a69 commit 88f6024

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/moduleEnv.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use strict";
22

33
var Module = require("module"),
4-
fs = require("fs");
4+
fs = require("fs"),
5+
coffee;
56

67
// caching original wrapper
78
var moduleWrapper0 = Module.wrapper[0],
@@ -55,8 +56,7 @@ function restoreExtensions() {
5556
}
5657

5758
function coffeeExtension(module, filename) {
58-
var coffee = require("coffee-script"),
59-
content = stripBOM(fs.readFileSync(filename, "utf8"));
59+
var content = stripBOM(fs.readFileSync(filename, "utf8"));
6060

6161
content = coffee.compile(content, {
6262
filename: filename,
@@ -78,5 +78,11 @@ function stripBOM(content) {
7878
return content;
7979
}
8080

81+
try {
82+
coffee = require("coffee-script");
83+
} catch (err) {
84+
// We are not able to provide coffee-script support, but that's ok as long as the user doesn't want it.
85+
}
86+
8187
exports.load = load;
82-
exports.inject = inject;
88+
exports.inject = inject;

0 commit comments

Comments
 (0)