Skip to content
Permalink
Browse files
refactor: transform var to let/const (#131)
  • Loading branch information
erisu committed Dec 17, 2019
1 parent ed926ad commit b078844317e1e50d4b199fc7253b5efc85f49c9e
Showing 4 changed files with 11 additions and 11 deletions.
@@ -61,9 +61,9 @@ const known_opts = {
};
const shortHands = { var: ['--variable'], v: ['--version'], h: ['--help'] };

var cli_opts = nopt(known_opts, shortHands);
const cli_opts = nopt(known_opts, shortHands);

var cmd = cli_opts.argv.remain.shift();
const cmd = cli_opts.argv.remain.shift();

// Without these arguments, the commands will fail and print the usage anyway.
if (cli_opts.plugins_dir || cli_opts.project) {
@@ -19,5 +19,5 @@
// All plugman js API moved to cordova-lib. This is a temporary shim for
// dowstream packages that use plugman via js API.

var cordova_lib = require('cordova-lib');
const cordova_lib = require('cordova-lib');
module.exports = cordova_lib.plugman;
@@ -27,7 +27,7 @@ module.exports = {
install (cli_opts) {
assertRequiredOptions(cli_opts, ['platform', 'project', 'plugin']);

var opts = {
const opts = {
subdir: '.',
cli_variables: expandCliVariables(cli_opts.variable),
save: cli_opts.save || false,
@@ -47,7 +47,7 @@ module.exports = {
uninstall (cli_opts) {
assertRequiredOptions(cli_opts, ['platform', 'project', 'plugin']);

var opts = {
const opts = {
www_dir: cli_opts.www,
save: cli_opts.save || false,
projectRoot: cli_opts.project
@@ -67,7 +67,7 @@ module.exports = {

platform (cli_opts) {
assertRequiredOptions(cli_opts, ['platform_name']);
var operation = cli_opts.argv.remain[0] || '';
const operation = cli_opts.argv.remain[0] || '';
if (operation !== 'add' && operation !== 'remove') {
throw new Error(`Operation must be either 'add' or 'remove' but was '${operation}'`);
}
@@ -76,7 +76,7 @@ module.exports = {
},

createpackagejson (cli_opts) {
var plugin_path = cli_opts.argv.remain[0];
const plugin_path = cli_opts.argv.remain[0];
if (!plugin_path) {
throw new Error(`Missing required path to plugin`);
}
@@ -99,8 +99,8 @@ function assertRequiredOptions (options, requiredKeys) {

function expandCliVariables (cliVarList) {
return (cliVarList || []).reduce((cli_variables, variable) => {
var tokens = variable.split('=');
var key = tokens.shift().toUpperCase();
const tokens = variable.split('=');
const key = tokens.shift().toUpperCase();
if (/^[\w-_]+$/.test(key)) cli_variables[key] = tokens.join('=');
return cli_variables;
}, {});
@@ -17,8 +17,8 @@
under the License.
*/

var fs = require('fs');
var path = require('path');
const fs = require('fs');
const path = require('path');

const docsDir = path.join(__dirname, '../doc');

0 comments on commit b078844

Please sign in to comment.