Skip to content

Commit

Permalink
eslint upgrade fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Zabil Cheriya Maliackal <[email protected]>
  • Loading branch information
zabil committed Jun 14, 2024
1 parent e449820 commit 6351d6f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 61 deletions.
35 changes: 0 additions & 35 deletions .eslintrc.json

This file was deleted.

38 changes: 38 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import mocha from "eslint-plugin-mocha";

export default [
{
plugins: {
mocha
},
languageOptions: {
ecmaVersion: 8,
globals: {
node: true,
es6: true,
mocha: true
}
},
rules: {
curly: "error",
indent: [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"mocha/no-exclusive-tests": "error",
"no-console": "off",
quotes: [
"error",
"double"
],
semi: [
"error",
"always"
]
}
}
];
78 changes: 52 additions & 26 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,47 @@ var fs = require("fs-extra"),
child_process = require("child_process"),
CWD = process.cwd();

var localPath = function (relativePath) {
return relativePath ? path.resolve(CWD, relativePath) : path.resolve(CWD);
};
var localPath = (relativePath) =>
relativePath ? path.resolve(CWD, relativePath) : path.resolve(CWD);

var plugin = require(localPath("./js.json"));

var cleanDir = function (dirPath) {
var cleanDir = (dirPath) => {
try {
fs.removeSync(dirPath);
} catch (err) {
console.error("Error removing directory: %s", err.message);
}
};

var createDir = function (dirPath) {
var createDir = (dirPath) => {
try {
fs.ensureDirSync(dirPath);
} catch (err) {
console.error("Error creating directory: %s", err.message);
}
};

var recreateDir = function (dirPath) {
var recreateDir = (dirPath) => {
cleanDir(dirPath);
createDir(dirPath);
};

var prepareFiles = function () {
var prepareFiles = () => {
var buildDir = localPath("build"),
copyList = ["gauge-proto", "src", "skel", "index.js", "index.bat", "debug.bat", "js.json", "package.json", "package-lock.json", ".node-inspectorrc", "README.md"];
copyList = [
"gauge-proto",
"src",
"skel",
"index.js",
"index.bat",
"debug.bat",
"js.json",
"package.json",
"package-lock.json",
".node-inspectorrc",
"README.md",
];
try {
console.log("Installing dependencies...");
fs.removeSync("./node_modules");
Expand All @@ -48,19 +59,26 @@ var prepareFiles = function () {

try {
console.log("Updating git submodules...");
child_process.execSync("git submodule update --init --recursive", { cwd: localPath() });
child_process.execSync("git submodule update --init --recursive", {
cwd: localPath(),
});
} catch (err) {
console.error("Error updating submodules: %s", err.toString());
console.error(err.stack);
}

copyList.forEach(function (item) {
copyList.forEach((item) => {
try {
fs.copySync(localPath(item), path.join(buildDir, item), { clobber: true, filter: function (f) {
return !(/(\/.git|^\/build)/.test(f.split(localPath())[1]));
}});
fs.copySync(localPath(item), path.join(buildDir, item), {
clobber: true,
filter: (f) => !/(\/.git|^\/build)/.test(f.split(localPath())[1]),
});
} catch (err) {
console.error("Failed to copy %s to build directory: %s", item, err.message);
console.error(
"Failed to copy %s to build directory: %s",
item,
err.message,
);
console.error(err.stack);
}
});
Expand All @@ -73,47 +91,55 @@ var prepareFiles = function () {
}
};

var createPackage = function (callback) {
var createPackage = (callback) => {
var zip = archiver("zip"),
deployDir = localPath("deploy"),
buildDir = localPath("build"),
packageFile = `gauge-${plugin.id}-${plugin.version}.zip`;

callback = callback || function () {};
callback = callback || (() => { });

recreateDir(deployDir);
prepareFiles();

var package = fs.createWriteStream(path.join(deployDir, packageFile));
var packageStream = fs.createWriteStream(path.join(deployDir, packageFile));

zip.on("error", function (err) {
zip.on("error", (err) => {
throw err;
});

package.on("close", function () {
packageStream.on("close", () => {
console.log("Created: %s", path.join("deploy", packageFile));
console.log("To install this plugin, run:\n\t$ gauge install js --file %s", path.join("deploy", packageFile));
typeof callback == "function" && callback(path.join(deployDir, packageFile));
console.log(
"To install this plugin, run:\n\t$ gauge install js --file %s",
path.join("deploy", packageFile),
);
typeof callback == "function" &&
callback(path.join(deployDir, packageFile));
});

zip.pipe(package);
zip.pipe(packageStream);

zip.directory(buildDir, "/").finalize();
};

var installPluginFiles = function () {
createPackage(function (packageFilePath) {
var installPluginFiles = () => {
createPackage((packageFilePath) => {
var log;

try {
log = child_process.execSync("gauge uninstall " + plugin.id + " --version \"" + plugin.version + "\"");
log = child_process.execSync(
`gauge uninstall ${plugin.id} --version "${plugin.version}"`,
);
console.log(log.toString());
} catch (err) {
console.error("Could not uninstall existing plugin: %s", err.message);
}

try {
log = child_process.execSync("gauge install " + plugin.id + " --file \"" + packageFilePath + "\"");
log = child_process.execSync(
`gauge install ${plugin.id} --file "${packageFilePath}"`,
);
console.log(log.toString());
} catch (err) {
console.error("Failed to install plugin: %s", err.message);
Expand Down

0 comments on commit 6351d6f

Please sign in to comment.