Bug 1374670 - Enabled the ESLint no-tabs rule across mozilla-central r=standard8

MozReview-Commit-ID: RT5QTipaOW
This commit is contained in:
Rajesh Kathiriya
2017-07-04 21:30:18 +05:30
parent ebf9427084
commit bfb3762076
51 changed files with 352 additions and 350 deletions

View File

@@ -1,21 +1,21 @@
/* !
update.js
update.js
run $ npm install
run $ node unpdate.js
run $ npm install
run $ node unpdate.js
Downloads latest version of microformat-shiv and it tests form github repo
Files downloaded:
* microformat-shiv.js (note: modern version)
* lib
* test/interface-tests
* test/module-tests
* test/standards-tests
* test/static
Downloads latest version of microformat-shiv and it tests form github repo
Files downloaded:
* microformat-shiv.js (note: modern version)
* lib
* test/interface-tests
* test/module-tests
* test/standards-tests
* test/static
Copyright (C) 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
Copyright (C) 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
// configuration
var deployDir = "../";
@@ -23,47 +23,47 @@ var exportedSymbol = 'try {\n // mozilla jsm support\n Components.utils.im
var path = require("path"),
request = require("request"),
fs = require("fs-extra"),
download = require("download-github-repo");
var path = require("path"),
request = require("request"),
fs = require("fs-extra"),
download = require("download-github-repo");
var repo = "glennjones/microformat-shiv",
tempDir = path.resolve(__dirname, "temp-repo"),
deployDirResolved = path.resolve(__dirname, deployDir),
pathList = [
["/modern/microformat-shiv-modern.js", "/microformat-shiv.js"],
["/lib", "/test/lib"],
["/test/interface-tests", "/test/interface-tests"],
["/test/module-tests", "/test/module-tests"],
["/test/standards-tests", "/test/standards-tests"],
["/test/static", "/test/static"]
];
tempDir = path.resolve(__dirname, "temp-repo"),
deployDirResolved = path.resolve(__dirname, deployDir),
pathList = [
["/modern/microformat-shiv-modern.js", "/microformat-shiv.js"],
["/lib", "/test/lib"],
["/test/interface-tests", "/test/interface-tests"],
["/test/module-tests", "/test/module-tests"],
["/test/standards-tests", "/test/standards-tests"],
["/test/static", "/test/static"]
];
getLastBuildState( repo, function( err, buildState) {
if (buildState) {
console.log("last build state:", buildState);
if (buildState) {
console.log("last build state:", buildState);
if (buildState === "passed") {
if (buildState === "passed") {
console.log("downloading git repo", repo);
getLastCommitDate( repo, function( err, date) {
if (date) {
console.log( "last commit:", new Date(date).toString() );
}
});
updateFromRepo();
console.log("downloading git repo", repo);
getLastCommitDate( repo, function( err, date) {
if (date) {
console.log( "last commit:", new Date(date).toString() );
}
});
updateFromRepo();
} else {
console.log("not updating because of build state is failing please contact Glenn Jones glennjones@gmail.com");
}
} else {
console.log("not updating because of build state is failing please contact Glenn Jones glennjones@gmail.com");
}
} else {
console.log("could not get build state from travis-ci:", err);
}
} else {
console.log("could not get build state from travis-ci:", err);
}
});
@@ -72,27 +72,27 @@ getLastBuildState( repo, function( err, buildState) {
*
*/
function updateFromRepo() {
download(repo, tempDir, function(err, data) {
download(repo, tempDir, function(err, data) {
// the err and data from download-github-repo give false negatives
if ( fs.existsSync( tempDir ) ) {
// the err and data from download-github-repo give false negatives
if ( fs.existsSync( tempDir ) ) {
var version = getRepoVersion();
removeCurrentFiles( pathList, deployDirResolved );
addNewFiles( pathList, deployDirResolved );
fs.removeSync(tempDir);
var version = getRepoVersion();
removeCurrentFiles( pathList, deployDirResolved );
addNewFiles( pathList, deployDirResolved );
fs.removeSync(tempDir);
// changes files for firefox
replaceInFile("/test/module-tests/index.html", /..\/..\/lib\//g, "../lib/" );
addExportedSymbol( "/microformat-shiv.js" );
// changes files for firefox
replaceInFile("/test/module-tests/index.html", /..\/..\/lib\//g, "../lib/" );
addExportedSymbol( "/microformat-shiv.js" );
console.log("microformat-shiv is now uptodate to v" + version);
console.log("microformat-shiv is now uptodate to v" + version);
} else {
console.log("error getting repo", err);
}
} else {
console.log("error getting repo", err);
}
});
});
}
@@ -103,10 +103,10 @@ function updateFromRepo() {
* @param {String} deployDirResolved
*/
function removeCurrentFiles( pathList, deployDirResolved ) {
pathList.forEach( function( path ) {
console.log("removed:", deployDirResolved + path[1]);
fs.removeSync(deployDirResolved + path[1]);
});
pathList.forEach( function( path ) {
console.log("removed:", deployDirResolved + path[1]);
fs.removeSync(deployDirResolved + path[1]);
});
}
@@ -117,10 +117,10 @@ function removeCurrentFiles( pathList, deployDirResolved ) {
* @param {String} deployDirResolved
*/
function addNewFiles( pathList, deployDirResolved ) {
pathList.forEach( function( path ) {
console.log("added:", deployDirResolved + path[1]);
fs.copySync(tempDir + path[0], deployDirResolved + path[1]);
});
pathList.forEach( function( path ) {
console.log("added:", deployDirResolved + path[1]);
fs.copySync(tempDir + path[0], deployDirResolved + path[1]);
});
}
@@ -131,14 +131,14 @@ function addNewFiles( pathList, deployDirResolved ) {
* @return {String}
*/
function getRepoVersion() {
var pack = fs.readFileSync(path.resolve(tempDir, "package.json"), {encoding: "utf8"});
if (pack) {
pack = JSON.parse(pack)
if (pack && pack.version) {
return pack.version;
}
}
return "";
var pack = fs.readFileSync(path.resolve(tempDir, "package.json"), {encoding: "utf8"});
if (pack) {
pack = JSON.parse(pack)
if (pack && pack.version) {
return pack.version;
}
}
return "";
}
@@ -150,26 +150,26 @@ function getRepoVersion() {
*/
function getLastCommitDate( repo, callback ) {
var options = {
url: "https://api.github.com/repos/" + repo + "/commits?per_page=1",
headers: {
"User-Agent": "request"
}
};
var options = {
url: "https://api.github.com/repos/" + repo + "/commits?per_page=1",
headers: {
"User-Agent": "request"
}
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
var date = null,
json = JSON.parse(body);
if (json && json.length && json[0].commit && json[0].commit.author ) {
date = json[0].commit.author.date;
}
callback(null, date);
} else {
console.log(error, response, body);
callback("fail to get last commit date", null);
}
});
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
var date = null,
json = JSON.parse(body);
if (json && json.length && json[0].commit && json[0].commit.author ) {
date = json[0].commit.author.date;
}
callback(null, date);
} else {
console.log(error, response, body);
callback("fail to get last commit date", null);
}
});
}
@@ -181,27 +181,27 @@ function getLastCommitDate( repo, callback ) {
*/
function getLastBuildState( repo, callback ) {
var options = {
url: "https://api.travis-ci.org/repos/" + repo,
headers: {
"User-Agent": "request",
"Accept": "application/vnd.travis-ci.2+json"
}
};
var options = {
url: "https://api.travis-ci.org/repos/" + repo,
headers: {
"User-Agent": "request",
"Accept": "application/vnd.travis-ci.2+json"
}
};
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
var buildState = null,
json = JSON.parse(body);
if (json && json.repo && json.repo.last_build_state ) {
buildState = json.repo.last_build_state;
}
callback(null, buildState);
} else {
console.log(error, response, body);
callback("fail to get last build state", null);
}
});
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
var buildState = null,
json = JSON.parse(body);
if (json && json.repo && json.repo.last_build_state ) {
buildState = json.repo.last_build_state;
}
callback(null, buildState);
} else {
console.log(error, response, body);
callback("fail to get last build state", null);
}
});
}
@@ -212,10 +212,10 @@ function getLastBuildState( repo, callback ) {
* @param {String} content
*/
function addExportedSymbol( path ) {
if (path === "/microformat-shiv.js") {
fs.appendFileSync(deployDirResolved + "/microformat-shiv.js", "\r\n" + exportedSymbol + "\r\n");
console.log("appended exported symbol to microformat-shiv.js");
}
if (path === "/microformat-shiv.js") {
fs.appendFileSync(deployDirResolved + "/microformat-shiv.js", "\r\n" + exportedSymbol + "\r\n");
console.log("appended exported symbol to microformat-shiv.js");
}
}
@@ -226,15 +226,15 @@ function addExportedSymbol( path ) {
* @param {String} content
*/
function replaceInFile( path, findStr, replaceStr ) {
readFile(deployDirResolved + path, function(err, fileStr) {
if (fileStr) {
fileStr = fileStr.replace(findStr, replaceStr)
writeFile(deployDirResolved + path, fileStr);
console.log("replaced " + findStr + " with " + replaceStr + " in " + path);
} else {
console.log("error replaced strings in " + path);
}
})
readFile(deployDirResolved + path, function(err, fileStr) {
if (fileStr) {
fileStr = fileStr.replace(findStr, replaceStr)
writeFile(deployDirResolved + path, fileStr);
console.log("replaced " + findStr + " with " + replaceStr + " in " + path);
} else {
console.log("error replaced strings in " + path);
}
})
}
@@ -245,13 +245,13 @@ function replaceInFile( path, findStr, replaceStr ) {
* @param {String} content
*/
function writeFile(path, content) {
fs.writeFile(path, content, "utf8", function(err) {
if (err) {
console.log(err);
} else {
console.log("The file: " + path + " was saved");
}
});
fs.writeFile(path, content, "utf8", function(err) {
if (err) {
console.log(err);
} else {
console.log("The file: " + path + " was saved");
}
});
}
@@ -262,5 +262,5 @@ function writeFile(path, content) {
* @param {Function} callback
*/
function readFile(path, callback) {
fs.readFile(path, "utf8", callback);
fs.readFile(path, "utf8", callback);
}