summaryrefslogtreecommitdiff
path: root/lib/module.js
diff options
context:
space:
mode:
authorDave Eddy <dave@daveeddy.com>2015-08-17 17:33:13 -0400
committerRod Vagg <rod@vagg.org>2015-10-03 21:58:38 +1000
commit2e6ece44e176f70a9c5c03879f4c98b912c7afbd (patch)
treeebfbbcef3ef560a6fe2f4a8e3566e4bc3d665a09 /lib/module.js
parent5bbc6df7ded6187de7e13dc10ebf89d59886165c (diff)
downloadandroid-node-v8-2e6ece44e176f70a9c5c03879f4c98b912c7afbd.tar.gz
android-node-v8-2e6ece44e176f70a9c5c03879f4c98b912c7afbd.tar.bz2
android-node-v8-2e6ece44e176f70a9c5c03879f4c98b912c7afbd.zip
node: add -c|--check CLI arg to syntax check script
PR-URL: https://github.com/nodejs/node/pull/2411 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r--lib/module.js16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/module.js b/lib/module.js
index da8a906f95..b1091ca66d 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -2,6 +2,7 @@
const NativeModule = require('native_module');
const util = require('util');
+const internalModule = require('internal/module');
const internalUtil = require('internal/util');
const runInThisContext = require('vm').runInThisContext;
const assert = require('assert').ok;
@@ -435,21 +436,10 @@ Module.prototype._compile = function(content, filename) {
};
-function stripBOM(content) {
- // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
- // because the buffer-to-string conversion in `fs.readFileSync()`
- // translates it to FEFF, the UTF-16 BOM.
- if (content.charCodeAt(0) === 0xFEFF) {
- content = content.slice(1);
- }
- return content;
-}
-
-
// Native extension for .js
Module._extensions['.js'] = function(module, filename) {
var content = fs.readFileSync(filename, 'utf8');
- module._compile(stripBOM(content), filename);
+ module._compile(internalModule.stripBOM(content), filename);
};
@@ -457,7 +447,7 @@ Module._extensions['.js'] = function(module, filename) {
Module._extensions['.json'] = function(module, filename) {
var content = fs.readFileSync(filename, 'utf8');
try {
- module.exports = JSON.parse(stripBOM(content));
+ module.exports = JSON.parse(internalModule.stripBOM(content));
} catch (err) {
err.message = filename + ': ' + err.message;
throw err;