kopia lustrzana https://github.com/c9/core
cleanup
rodzic
766d3039d7
commit
413d628c80
|
@ -1,3 +1,5 @@
|
||||||
|
// build script to bundle eslint and eslint-plugin-react in a format usable by language worker
|
||||||
|
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
|
@ -7,6 +9,7 @@ function changeFile(filepath, handler, ignoreBackup) {
|
||||||
value = fs.readFileSync(filepath + ".bak", "utf8");
|
value = fs.readFileSync(filepath + ".bak", "utf8");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
value = fs.readFileSync(filepath, "utf8");
|
value = fs.readFileSync(filepath, "utf8");
|
||||||
|
// backup the file in case the script is invoked again without clean npm install
|
||||||
if (!ignoreBackup)
|
if (!ignoreBackup)
|
||||||
fs.writeFileSync(filepath + ".bak", value, "utf8");
|
fs.writeFileSync(filepath + ".bak", value, "utf8");
|
||||||
}
|
}
|
||||||
|
@ -22,15 +25,21 @@ function changeFile(filepath, handler, ignoreBackup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function safeReplace(src, pattern, value, count) {
|
function safeReplace(src, pattern, value, count) {
|
||||||
var n = 0;
|
var matchCount = 0;
|
||||||
|
var replacer = value
|
||||||
|
if (typeof replacer == "string") {
|
||||||
|
replacer = function(...args) {
|
||||||
|
// expand placeholders of form $i in the replacement string
|
||||||
|
return value.replace(/[$](\d)/g, (_, i) => args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
src = src.replace(pattern, function(...args) {
|
src = src.replace(pattern, function(...args) {
|
||||||
n++;
|
matchCount++;
|
||||||
if (typeof value == "function")
|
return replacer(...args);
|
||||||
return value.apply(this, args);
|
|
||||||
return value.replace(/\$(\d)/g, (_, i) => args[i]);
|
|
||||||
});
|
});
|
||||||
// if (count != undefined && n != count)
|
if (count != undefined && count != matchCount)
|
||||||
// throw new Error(`expected "${pattern}" to match ${count} times instead of ${n}`);
|
throw new Error(`expected "${pattern}" to match ${count} times instead of ${n}`);
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +47,9 @@ var loadRulesPath = require.resolve("eslint/lib/load-rules");
|
||||||
var contents = `module.exports = function() {
|
var contents = `module.exports = function() {
|
||||||
var rules = {`;
|
var rules = {`;
|
||||||
|
|
||||||
fs.readdirSync(path.join(loadRulesPath, "../rules")).forEach((file) => {
|
var ruleNames = fs.readdirSync(path.join(loadRulesPath, "../rules"));
|
||||||
if (path.extname(file) == ".js") {
|
ruleNames.forEach(function(file) {
|
||||||
|
if (file.endsWith(".js")) {
|
||||||
file = file.slice(0, -3);
|
file = file.slice(0, -3);
|
||||||
contents += ' "' + file + '": ' + 'require("eslint/lib/rules/' + file + '"),\n';
|
contents += ' "' + file + '": ' + 'require("eslint/lib/rules/' + file + '"),\n';
|
||||||
}
|
}
|
||||||
|
@ -108,7 +118,7 @@ webpack({
|
||||||
}
|
}
|
||||||
}, (err, stats) => {
|
}, (err, stats) => {
|
||||||
if (err || stats.hasErrors()) {
|
if (err || stats.hasErrors()) {
|
||||||
console.log(err, stats);
|
return console.log(err, stats);
|
||||||
}
|
}
|
||||||
var commentRe = /^(;)?(?:\s*(?:\/\/.+\n|\/\*(?:[^*]|\*(?!\/))*\*\/))+(?: *\n)?/gm;
|
var commentRe = /^(;)?(?:\s*(?:\/\/.+\n|\/\*(?:[^*]|\*(?!\/))*\*\/))+(?: *\n)?/gm;
|
||||||
changeFile(outputPath, function(src) {
|
changeFile(outputPath, function(src) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ var address = system.args[1];
|
||||||
var filter = system.args[2];
|
var filter = system.args[2];
|
||||||
var branch = system.args[3];
|
var branch = system.args[3];
|
||||||
|
|
||||||
var logAll = !false;
|
var logAll = true;
|
||||||
if (!address) console.log("# No address, running against: ", TEST_SUITE_URL);
|
if (!address) console.log("# No address, running against: ", TEST_SUITE_URL);
|
||||||
if (filter) console.log("# Filter tests by ", filter);
|
if (filter) console.log("# Filter tests by ", filter);
|
||||||
if (!address) address = TEST_SUITE_URL;
|
if (!address) address = TEST_SUITE_URL;
|
||||||
|
|
Ładowanie…
Reference in New Issue