Introduce ESLint and Prettier

This commit is contained in:
Zaid Abdulla committed 2018-08-24 05:31:22 -07:00
1 parent 9c943d0bbf
commit e494bdca8a
26 files changed
+1585 -1594

No files matched your search

+12 -13
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2017 Zaid Abdulla
* Copyright 2013-2018 Zaid Abdulla
*
* This file is part of GenieACS.
*
@@ -23,11 +23,9 @@ const fileName = process.argv[2];
let script;
function errorToFault(err) {
if (!err)
return null;
if (!err) return null;
if (!err.name)
return {code: "ext", message: `${err}`};
if (!err.name) return { code: "ext", message: `${err}` };
let fault = {
code: `ext.${err.name}`,
@@ -41,7 +39,9 @@ function errorToFault(err) {
if (err.stack) {
fault.detail.stack = err.stack;
// Trim the stack trace
let stackTrimIndex = fault.detail.stack.match(/\s+at\s[^\s]+\s\(.*extension-wrapper\.js:.+\)/);
let stackTrimIndex = fault.detail.stack.match(
/\s+at\s[^\s]+\s\(.*extension-wrapper\.js:.+\)/
);
if (stackTrimIndex)
fault.detail.stack = fault.detail.stack.slice(0, stackTrimIndex.index);
}
@@ -49,16 +49,16 @@ function errorToFault(err) {
return fault;
}
process.on("uncaughtException", function(err) {
process.on("uncaughtException", err => {
let fault = errorToFault(err);
jobs.forEach(function(jobId) {
jobs.forEach(jobId => {
process.send([jobId, fault]);
});
jobs.clear();
process.disconnect();
});
process.on("message", function(message) {
process.on("message", message => {
jobs.add(message[0]);
if (!script) {
@@ -78,13 +78,12 @@ process.on("message", function(message) {
return;
}
script[funcName](message[1].slice(1), function(err, res) {
if (!jobs.delete(message[0]))
return;
script[funcName](message[1].slice(1), (err, res) => {
if (!jobs.delete(message[0])) return;
process.send([message[0], errorToFault(err), res]);
});
});
// Ignore SIGINT
process.on('SIGINT', function() {});
process.on("SIGINT", () => {});