Skip to content

Commit

Permalink
style: apply eslint auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Dec 17, 2021
1 parent a20558d commit 4e86379
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion cordova.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// All cordova js API moved to cordova-lib. If you don't need the cordova CLI,
// use cordova-lib directly.

var cordova_lib = require('cordova-lib');
const cordova_lib = require('cordova-lib');
module.exports = cordova_lib.cordova;

// Also export the cordova-lib so that downstream consumers of cordova lib and
Expand Down
102 changes: 51 additions & 51 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
under the License.
*/

var nopt = require('nopt');
var updateNotifier = require('update-notifier');
var pkg = require('../package.json');
var telemetry = require('./telemetry');
var help = require('./help');
const nopt = require('nopt');
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');
const telemetry = require('./telemetry');
const help = require('./help');
const info = require('./info');
var cordova_lib = require('cordova-lib');
var CordovaError = cordova_lib.CordovaError;
var cordova = cordova_lib.cordova;
var events = cordova_lib.events;
var logger = require('cordova-common').CordovaLogger.get();
var cordovaCreate = require('cordova-create');
var Configstore = require('configstore');
var conf = new Configstore(pkg.name + '-config');
var editor = require('editor');
const cordova_lib = require('cordova-lib');
const CordovaError = cordova_lib.CordovaError;
const cordova = cordova_lib.cordova;
const events = cordova_lib.events;
const logger = require('cordova-common').CordovaLogger.get();
const cordovaCreate = require('cordova-create');
const Configstore = require('configstore');
const conf = new Configstore(pkg.name + '-config');
const editor = require('editor');
const semver = require('semver');

// process.version is not declared writable or has no setter so storing in const for Jasmine.
Expand All @@ -39,7 +39,7 @@ const NODE_VERSION = process.version;
const NODE_VERSION_REQUIREMENT = false;
const NODE_VERSION_DEPRECATING_RANGE = '<10';

var knownOpts = {
const knownOpts = {
verbose: Boolean,
version: Boolean,
help: Boolean,
Expand Down Expand Up @@ -69,7 +69,7 @@ var knownOpts = {
noprod: Boolean
};

var shortHands = {
const shortHands = {
d: '--verbose',
v: '--version',
h: '--help',
Expand All @@ -79,7 +79,7 @@ var shortHands = {
function checkForUpdates () {
try {
// Checks for available update and returns an instance
var notifier = updateNotifier({ pkg: pkg });
const notifier = updateNotifier({ pkg: pkg });

if (notifier.update &&
notifier.update.latest !== pkg.version) {
Expand All @@ -97,15 +97,15 @@ function checkForUpdates () {
}
}

var shouldCollectTelemetry = false;
let shouldCollectTelemetry = false;

module.exports = function (inputArgs) {
// If no inputArgs given, use process.argv.
inputArgs = inputArgs || process.argv;
var cmd = inputArgs[2]; // e.g: inputArgs= 'node cordova run ios'
var subcommand = getSubCommand(inputArgs, cmd);
var isTelemetryCmd = (cmd === 'telemetry');
var isConfigCmd = (cmd === 'config');
let cmd = inputArgs[2]; // e.g: inputArgs= 'node cordova run ios'
const subcommand = getSubCommand(inputArgs, cmd);
const isTelemetryCmd = (cmd === 'telemetry');
const isConfigCmd = (cmd === 'config');

// ToDO: Move nopt-based parsing of args up here
if (cmd === '--version' || cmd === '-v') {
Expand Down Expand Up @@ -174,7 +174,7 @@ module.exports = function (inputArgs) {
* Also, if the user has already been prompted and made a decision, use his saved answer
*/
if (isTelemetryCmd) {
var isOptedIn = telemetry.isOptedIn();
const isOptedIn = telemetry.isOptedIn();
return handleTelemetryCmd(subcommand, isOptedIn);
}

Expand Down Expand Up @@ -213,7 +213,7 @@ function getSubCommand (args, cmd) {
}

function printHelp (command) {
var result = help([command]);
const result = help([command]);
cordova.emit('results', result);
}

Expand All @@ -224,8 +224,8 @@ function handleTelemetryCmd (subcommand, isOptedIn) {
return;
}

var turnOn = subcommand === 'on';
var cmdSuccess = true;
const turnOn = subcommand === 'on';
let cmdSuccess = true;

// turn telemetry on or off
try {
Expand Down Expand Up @@ -258,7 +258,7 @@ function handleTelemetryCmd (subcommand, isOptedIn) {
function cli (inputArgs) {
checkForUpdates();

var args = nopt(knownOpts, shortHands, inputArgs);
const args = nopt(knownOpts, shortHands, inputArgs);

process.on('uncaughtException', function (err) {
if (err.message) {
Expand All @@ -281,11 +281,11 @@ function cli (inputArgs) {
logger.setLevel('verbose');
}

var cliVersion = pkg.version;
var usingPrerelease = !!semver.prerelease(cliVersion);
const cliVersion = pkg.version;
const usingPrerelease = !!semver.prerelease(cliVersion);
if (args.version || usingPrerelease) {
var libVersion = require('cordova-lib/package').version;
var toPrint = cliVersion;
const libVersion = require('cordova-lib/package').version;
let toPrint = cliVersion;
if (cliVersion !== libVersion || usingPrerelease) {
toPrint += ' (cordova-lib@' + libVersion + ')';
}
Expand Down Expand Up @@ -325,19 +325,19 @@ function cli (inputArgs) {
// In this case "--verbose" is not parsed by nopt and args.vergbose will be
// false, the unparsed args after -- are kept in unparsedArgs and can be
// passed downstream to some scripts invoked by Cordova.
var unparsedArgs = [];
var parseStopperIdx = args.argv.original.indexOf('--');
let unparsedArgs = [];
const parseStopperIdx = args.argv.original.indexOf('--');
if (parseStopperIdx !== -1) {
unparsedArgs = args.argv.original.slice(parseStopperIdx + 1);
}

// args.argv.remain contains both the undashed args (like platform names)
// and whatever unparsed args that were protected by " -- ".
// "undashed" stores only the undashed args without those after " -- " .
var remain = args.argv.remain;
var undashed = remain.slice(0, remain.length - unparsedArgs.length);
var cmd = undashed[0];
var subcommand;
const remain = args.argv.remain;
const undashed = remain.slice(0, remain.length - unparsedArgs.length);
const cmd = undashed[0];
let subcommand;

if (!cmd || cmd === 'help' || args.help) {
if (!args.help && remain[0] === 'help') {
Expand All @@ -357,12 +357,12 @@ function cli (inputArgs) {
}

if (!Object.prototype.hasOwnProperty.call(cordova, cmd)) {
var msg2 = 'Cordova does not know ' + cmd + '; try `' + cordova_lib.binname +
const msg2 = 'Cordova does not know ' + cmd + '; try `' + cordova_lib.binname +
' help` for a list of all the available commands.';
throw new CordovaError(msg2);
}

var opts = {
const opts = {
platforms: [],
options: [],
verbose: args.verbose || false,
Expand All @@ -371,7 +371,7 @@ function cli (inputArgs) {
searchpath: args.searchpath
};

var platformCommands = ['emulate', 'build', 'prepare', 'compile', 'run', 'clean'];
const platformCommands = ['emulate', 'build', 'prepare', 'compile', 'run', 'clean'];
if (platformCommands.indexOf(cmd) !== -1) {
// All options without dashes are assumed to be platform names
opts.platforms = undashed.slice(1);
Expand All @@ -389,21 +389,21 @@ function cli (inputArgs) {

return cordova[cmd].call(null, opts.platforms)
.then(function (platformChecks) {
var someChecksFailed = Object.keys(platformChecks).map(function (platformName) {
const someChecksFailed = Object.keys(platformChecks).map(function (platformName) {
events.emit('log', '\nRequirements check results for ' + platformName + ':');
var platformCheck = platformChecks[platformName];
const platformCheck = platformChecks[platformName];
if (platformCheck instanceof CordovaError) {
events.emit('warn', 'Check failed for ' + platformName + ' due to ' + platformCheck);
return true;
}

var someChecksFailed = false;
let someChecksFailed = false;

// platformCheck is expected to be an array of conditions that must be met
// the browser platform currently returns nothing, which was breaking here.
if (platformCheck && platformCheck.forEach) {
platformCheck.forEach(function (checkItem) {
var checkSummary = checkItem.name + ': ' +
const checkSummary = checkItem.name + ': ' +
(checkItem.installed ? 'installed ' : 'not installed ') +
(checkItem.installed ? checkItem.metadata.version.version || checkItem.metadata.version : '');
events.emit('log', checkSummary);
Expand All @@ -423,22 +423,22 @@ function cli (inputArgs) {
}
});
} else if (cmd === 'serve') {
var port = undashed[1];
const port = undashed[1];
return cordova.serve(port);
} else {
// platform/plugins add/rm [target(s)]
subcommand = undashed[1]; // sub-command like "add", "ls", "rm" etc.
var targets = undashed.slice(2); // array of targets, either platforms or plugins
var cli_vars = {};
const targets = undashed.slice(2); // array of targets, either platforms or plugins
const cli_vars = {};
if (args.variable) {
args.variable.forEach(function (strVar) {
// CB-9171
var keyVal = strVar.split('=');
const keyVal = strVar.split('=');
if (keyVal.length < 2) {
throw new CordovaError('invalid variable format: ' + strVar);
} else {
var key = keyVal.shift().toUpperCase();
var val = keyVal.join('=');
const key = keyVal.shift().toUpperCase();
const val = keyVal.join('=');
cli_vars[key] = val;
}
});
Expand All @@ -456,7 +456,7 @@ function cli (inputArgs) {
args['save-exact'] = conf.get('save-exact');
}

var download_opts = {
const download_opts = {
searchpath: args.searchpath,
noregistry: args.noregistry,
nohooks: args.nohooks,
Expand Down
10 changes: 5 additions & 5 deletions src/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
specific language governing permissions and limitations
under the License.
*/
var fs = require('fs');
var cordova_lib = require('cordova-lib');
var path = require('path');
const fs = require('fs');
const cordova_lib = require('cordova-lib');
const path = require('path');

module.exports = function help (args) {
var command,
let command,
file,
raw,
docdir;
Expand All @@ -34,7 +34,7 @@ module.exports = function help (args) {
'cordova.md',
'cordova.txt'
].map(function (file) {
var f = path.join(docdir, file);
const f = path.join(docdir, file);
if (fs.existsSync(f)) {
return f;
}
Expand Down
10 changes: 5 additions & 5 deletions src/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
const { EOL } = require('os');

// Google Analytics tracking code
var GA_TRACKING_CODE = 'UA-64283057-7';
const GA_TRACKING_CODE = 'UA-64283057-7';

var pkg = require('../package.json');
var Insight = require('insight');
const pkg = require('../package.json');
const Insight = require('insight');

/**
* By redefining `get optOut` we trick Insight into tracking
Expand All @@ -38,7 +38,7 @@ class RelentlessInsight extends Insight {
get realOptOut () { return super.optOut; }
}

var insight = new RelentlessInsight({
const insight = new RelentlessInsight({
trackingCode: GA_TRACKING_CODE,
pkg: pkg
});
Expand Down Expand Up @@ -96,7 +96,7 @@ function isOptedIn () {
* Has the user already answered the telemetry prompt? (thereby opting in or out?)
*/
function hasUserOptedInOrOut () {
var insightOptOut = insight.realOptOut === undefined;
const insightOptOut = insight.realOptOut === undefined;
return !(insightOptOut);
}

Expand Down

0 comments on commit 4e86379

Please sign in to comment.