remove env from all environment calls except the ones that actually need it

This commit is contained in:
Luke Page
2014-09-21 16:46:44 +01:00
parent a53be80014
commit fb6c879cc4
9 changed files with 43 additions and 43 deletions

View File

@@ -5,25 +5,25 @@ var path = require('path'),
isUrlRe = /^(?:https?:)?\/\//i;
module.exports = {
warn: function(env, msg) {
warn: function(msg) {
console.warn(msg);
},
encodeBase64: function encodeBase64(env, str) {
encodeBase64: function encodeBase64(str) {
return new Buffer(str).toString('base64');
},
supportsDataURI: function(env) {
supportsDataURI: function() {
return true;
},
mimeLookup: function (env, filename) {
mimeLookup: function (filename) {
return require('mime').lookup(filename);
},
charsetLookup: function (env, mime) {
charsetLookup: function (mime) {
return require('mime').charsets.lookup(mime);
},
readFileSync: function (filename) {
return require("fs").readFileSync(filename);
},
getPath: function (env, filename) {
getPath: function (filename) {
var j = filename.lastIndexOf('/');
if (j < 0) {
j = filename.lastIndexOf('\\');
@@ -33,10 +33,10 @@ module.exports = {
}
return filename.slice(0, j + 1);
},
isPathAbsolute: function(env, filename) {
isPathAbsolute: function(filename) {
return (/^(?:[a-z-]+:|\/|\\)/i).test(filename);
},
getAbsolutePath: function getAbsolutePath(env, filename) {
getAbsolutePath: function getAbsolutePath(filename) {
return require('path').resolve(filename);
},
getSourceMapGenerator: function getSourceMapGenerator() {
@@ -128,11 +128,13 @@ module.exports = {
returner.url = returner.fileUrl + (urlParts[5] || "");
return returner;
},
loadFile: function(env, filename, currentDirectory, callback) {
loadFile: function(filename, currentDirectory, options, callback) {
var fullFilename,
data,
isUrl = isUrlRe.test( filename );
options = options || {};
if (isUrl || isUrlRe.test(currentDirectory)) {
if (request === undefined) {
try { request = require('request'); }
@@ -151,7 +153,7 @@ module.exports = {
urlStr = urlObj.format();
}
request.get({uri: urlStr, strictSSL: !env.insecure }, function (error, res, body) {
request.get({uri: urlStr, strictSSL: !options.insecure }, function (error, res, body) {
if (error) {
callback({ type: 'File', message: "resource '" + urlStr + "' gave this Error:\n "+ error +"\n" });
}
@@ -160,7 +162,7 @@ module.exports = {
return;
}
if (!body) {
this.warn( env, 'Warning: Empty body (HTTP '+ res.statusCode + ') returned by "' + urlStr +'"');
this.warn('Warning: Empty body (HTTP '+ res.statusCode + ') returned by "' + urlStr +'"');
}
fullFilename = urlStr;
callback(null, body, fullFilename);
@@ -168,10 +170,10 @@ module.exports = {
} else {
var paths = [currentDirectory];
if (env.paths) paths.push.apply(paths, env.paths);
if (options.paths) paths.push.apply(paths, options.paths);
if (paths.indexOf('.') === -1) paths.push('.');
if (env.syncImport) {
if (options.syncImport) {
for (var i = 0; i < paths.length; i++) {
try {
fullFilename = path.join(paths[i], filename);