chore: fix whitespace in inline.js

test-unit-sauce
Brian Ford 10 years ago
parent 13d23765b2
commit e4a68061ae

@ -2,26 +2,33 @@
// This is a really dumb naive approach that only supports `module.exports =` // This is a really dumb naive approach that only supports `module.exports =`
var fs = require('fs'); var fs = require('fs');
var r = new RegExp("( *).*?require\\('(.+?)'\\)", 'g');
var debug = fs.readFileSync(__dirname + '/../content-scripts/inject.js', 'utf8'); module.exports = function () {
var debug = fs.readFileSync(__dirname + '/../content-scripts/inject.js', 'utf8');
var r = new RegExp("require\\('(.+?)'\\)", 'g'); var out = debug.replace(r, function (match, before, file) {
return ex(file, before);
});
var out = debug.replace(r, function (match, file) { fs.writeFileSync(__dirname + '/../content-scripts/inject.build.js', out);
return ex(file); };
});
fs.writeFileSync(__dirname + '/../content-scripts/inject.build.js', out);
// takes the contents of a file, wraps it in a closure // takes the contents of a file, wraps it in a closure
// and returns the result // and returns the result
function ex (file) { function ex (file, whitespace) {
contents = fs.readFileSync(__dirname + '/../content-scripts/' + file, 'utf8'); var contents = fs.readFileSync(__dirname + '/../content-scripts/' + file, 'utf8');
contents = contents.replace('module.exports = ', 'return '); contents = contents.replace('module.exports = ', 'return ');
contents = '(function () {\n' + contents = ['// exported from ' + file,
'// exported from ' + file + '\n' + '(function () {'].
contents + '\n' + concat(contents.split('\n').
'}())'; map(function (line) {
return ' ' + line;
})).
concat(['}())']).
map(function (line) {
return whitespace + line;
}).join('\n');
return contents; return contents;
} }