Skip to content

Commit

Permalink
Lint JavaScript files only
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Aug 17, 2023
1 parent e11ebbe commit 09bb3d2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
env: {
node: true,
},
ignorePatterns: ['node_modules', 'package.json', 'package-lock.json'],
extends: ['eslint:recommended'],
rules: {
quotes: ['error', 'single'],
Expand Down
38 changes: 19 additions & 19 deletions bin/autobump
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/usr/bin/env node

var fs = require("fs");
var path = require("path");
var semver = require("semver");
var request = require("request");
var exec = require("child_process").exec;
var fs = require('fs');
var path = require('path');
var semver = require('semver');
var request = require('request');
var exec = require('child_process').exec;

var url = "https://raw.github.com/rogerwang/node-webkit/master/README.md";
var pkgpath = path.join(__dirname, "..", "package.json");
var url = 'https://raw.github.com/rogerwang/node-webkit/master/README.md';
var pkgpath = path.join(__dirname, '..', 'package.json');

// Download README file
var readme = request(url);
var data = "";
readme.on("data", function (buf) {
var data = '';
readme.on('data', function (buf) {
data += buf;
});
readme.on("end", function () {
readme.on('end', function () {
var version = semver.clean(/\[v([^\s]+)\s+release notes\]/i.exec(data)[1]);
// Version invalid so quit
if (!semver.valid(version)) {
console.error("INVALID VERSION: " + version);
console.error('INVALID VERSION: ' + version);
process.exit();
}
var pkg = require(pkgpath);
Expand All @@ -29,27 +29,27 @@ readme.on("end", function () {
pkg.version = version;
fs.writeFileSync(pkgpath, JSON.stringify(pkg, null, 2));

console.log("PUBLISHING NEW VERSION " + version);
console.log('PUBLISHING NEW VERSION ' + version);

var cmd = [
"git add package.json",
'git add package.json',
'git commit -m "v' + version + '"',
"git push origin master",
"npm publish",
].join(" && ");
'git push origin master',
'npm publish',
].join(' && ');
exec(
cmd,
{ cwd: path.resolve(__dirname, "..") },
{ cwd: path.resolve(__dirname, '..') },
function (err, stdout, stderr) {
if (err || stderr) {
// Revert package.json change and try again next time
console.error("FAILED");
console.error('FAILED');
console.error(err || stderr);
pkg.version = currentversion;
fs.writeFileSync(pkgpath, JSON.stringify(pkg, null, 2));
// TODO: Should revert commit here as well
} else {
console.log("SUCCESS");
console.log('SUCCESS');
}
},
);
Expand Down
34 changes: 18 additions & 16 deletions bin/nw
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#!/usr/bin/env node

var fs = require("fs");
var path = require("path");
var spawn = require("child_process").spawn;
var bin = require("../lib/findpath.js")();
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var bin = require('../lib/findpath.js')();

function run() {
// Rename nw.js's own package.json as workaround for https://github.com/nwjs/nw.js/issues/1503
var packagejson = path.resolve(__dirname, "..", "package.json");
var packagejsonBackup = path.resolve(__dirname, "..", "package_backup.json");
var packagejson = path.resolve(__dirname, '..', 'package.json');
var packagejsonBackup = path.resolve(__dirname, '..', 'package_backup.json');
if (!fs.existsSync(packagejsonBackup)) {
try {
fs.renameSync(packagejson, packagejsonBackup);
} catch (err) {}
}

// copy over any asset files (icons, etc) specified via CLI args:
require("../lib/app_assets").copyAssets(process.platform, bin);
require('../lib/app_assets').copyAssets(process.platform, bin);

// Normalize cli args
var args = process.argv.slice(2);
var cwd = args.length < 1 ? "." : args[0];
var cwd = args.length < 1 ? '.' : args[0];
if (!fs.existsSync(path.resolve(cwd))) {
args = ["."].concat(args);
args = ['.'].concat(args);
} else {
args = [cwd].concat(args.slice(1));
}

// Spawn node-webkit
var nw = spawn(bin, args, { stdio: "inherit" });
nw.on("close", function () {
var nw = spawn(bin, args, { stdio: 'inherit' });
nw.on('close', function () {
process.nextTick(function () {
process.exit(0);
});
Expand All @@ -41,20 +41,22 @@ function run() {
if (fs.existsSync(packagejsonBackup)) {
fs.renameSync(packagejsonBackup, packagejson);
}
} catch (err) {}
} catch (err) {
console.error(err);
}
}, 1000);
}

if (!fs.existsSync(bin)) {
console.log(
"nw.js appears to have failed to download and extract. Attempting to download and extract again...",
'nw.js appears to have failed to download and extract. Attempting to download and extract again...',
);
var child = spawn(
process.execPath,
[path.resolve(__dirname, "..", "scripts", "install.js")],
{ stdio: "inherit" },
[path.resolve(__dirname, '..', 'scripts', 'install.js')],
{ stdio: 'inherit' },
);
child.on("close", run);
child.on('close', run);
} else {
run();
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
"scripts": {
"postinstall": "node scripts/install.js",
"lint": "eslint --config=.github/eslint.config.js --fix .",
"lint:check": "eslint --config=.github/eslint.config.js .",
"lint": "eslint --config=.github/eslint.config.js --fix ./**/*.js",
"lint:check": "eslint --config=.github/eslint.config.js ./**/*.js",
"test": "node --test-reporter=spec --test test/index.mjs"
},
"files": [
Expand Down

0 comments on commit 09bb3d2

Please sign in to comment.