You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2022/02/06 17:58:22 UTC
[cordova-osx] 03/04: eslint --fix
This is an automated email from the ASF dual-hosted git repository.
niklasmerz pushed a commit to branch prepare-7.0.0
in repository https://gitbox.apache.org/repos/asf/cordova-osx.git
commit 4e7d860007abd0f9f4ebec1dc357de0638c5b249
Author: Niklas Merz <ni...@apache.org>
AuthorDate: Sun Feb 6 18:37:43 2022 +0100
eslint --fix
---
bin/apple_osx_version | 2 +-
bin/apple_xcode_version | 2 +-
bin/check_reqs | 2 +-
bin/create | 14 +--
bin/lib/check_reqs.js | 22 ++---
bin/lib/create.js | 70 +++++++-------
bin/lib/versions.js | 22 ++---
bin/templates/scripts/cordova/Api.js | 34 +++----
bin/templates/scripts/cordova/build | 10 +-
bin/templates/scripts/cordova/clean | 2 +-
bin/templates/scripts/cordova/lib/ConsoleLogger.js | 10 +-
bin/templates/scripts/cordova/lib/build.js | 32 +++----
bin/templates/scripts/cordova/lib/clean.js | 10 +-
bin/templates/scripts/cordova/lib/configMunger.js | 8 +-
.../scripts/cordova/lib/copy-www-build-step.js | 22 ++---
.../scripts/cordova/lib/plugman/Plugman.js | 56 +++++------
.../scripts/cordova/lib/plugman/pluginHandlers.js | 104 ++++++++++-----------
bin/templates/scripts/cordova/lib/prepare.js | 100 ++++++++++----------
bin/templates/scripts/cordova/lib/projectFile.js | 50 +++++-----
bin/templates/scripts/cordova/lib/run.js | 14 +--
bin/templates/scripts/cordova/lib/spawn.js | 4 +-
bin/templates/scripts/cordova/run | 10 +-
bin/templates/scripts/cordova/version | 2 +-
bin/update | 6 +-
bin/update_cordova_subproject | 4 +-
cordova-js-src/exec.js | 26 +++---
26 files changed, 319 insertions(+), 319 deletions(-)
diff --git a/bin/apple_osx_version b/bin/apple_osx_version
index b9c14e0..71aaa01 100755
--- a/bin/apple_osx_version
+++ b/bin/apple_osx_version
@@ -19,7 +19,7 @@
under the License.
*/
-var versions = require('./lib/versions.js');
+const versions = require('./lib/versions.js');
versions.get_apple_osx_version().catch(function (err) {
console.log(err);
diff --git a/bin/apple_xcode_version b/bin/apple_xcode_version
index 7647828..1c7ee0c 100755
--- a/bin/apple_xcode_version
+++ b/bin/apple_xcode_version
@@ -19,7 +19,7 @@
under the License.
*/
-var versions = require('./lib/versions.js');
+const versions = require('./lib/versions.js');
versions.get_apple_xcode_version().then(function (version) {
console.log(version);
diff --git a/bin/check_reqs b/bin/check_reqs
index 0ac8466..73a7bc8 100755
--- a/bin/check_reqs
+++ b/bin/check_reqs
@@ -19,7 +19,7 @@
under the License.
*/
-var check_reqs = require('./lib/check_reqs');
+const check_reqs = require('./lib/check_reqs');
// check for help flag
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) {
diff --git a/bin/create b/bin/create
index ec6c4e4..60e69da 100755
--- a/bin/create
+++ b/bin/create
@@ -29,16 +29,16 @@
* ./create ~/Desktop/radness org.apache.cordova.radness Radness
*/
-var path = require('path');
-var ConfigParser = require('cordova-common').ConfigParser;
-var Api = require('./templates/scripts/cordova/Api');
+const path = require('path');
+const ConfigParser = require('cordova-common').ConfigParser;
+const Api = require('./templates/scripts/cordova/Api');
-var argv = require('nopt')({
+const argv = require('nopt')({
help: Boolean,
link: Boolean
});
-var projectPath = argv.argv.remain[0];
+const projectPath = argv.argv.remain[0];
if (argv.help || !projectPath) {
console.log('Usage: $0 [--link] <path_to_new_project> <package_name> <project_name> [<project_template_dir>]');
@@ -51,13 +51,13 @@ if (argv.help || !projectPath) {
}
// use default configuration file from project template
-var config = new ConfigParser(path.resolve(__dirname, 'templates/project/__PROJECT_NAME__/config.xml'));
+const config = new ConfigParser(path.resolve(__dirname, 'templates/project/__PROJECT_NAME__/config.xml'));
// apply overrides (package and project names
if (argv.argv.remain[1]) config.setPackageName(argv.argv.remain[1]);
if (argv.argv.remain[2]) config.setName(argv.argv.remain[2]);
-var options = {
+const options = {
link: argv.link,
customTemplate: argv.argv.remain[3]
};
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 7830e61..e2e3cbf 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -17,11 +17,11 @@
under the License.
*/
-var shell = require('shelljs');
-var versions = require('./versions');
+const shell = require('shelljs');
+const versions = require('./versions');
-var XCODEBUILD_MIN_VERSION = '6.0.0';
-var XCODEBUILD_NOT_FOUND_MESSAGE =
+const XCODEBUILD_MIN_VERSION = '6.0.0';
+const XCODEBUILD_NOT_FOUND_MESSAGE =
'Please install version ' + XCODEBUILD_MIN_VERSION + ' or greater from App Store';
/**
@@ -48,7 +48,7 @@ module.exports.check_os = function () {
*/
function checkTool (tool, minVersion, message) {
// Check whether tool command is available at all
- var tool_command = shell.which(tool);
+ const tool_command = shell.which(tool);
if (!tool_command) {
return Promise.reject(tool + ' was not found. ' + (message || ''));
}
@@ -69,7 +69,7 @@ function checkTool (tool, minVersion, message) {
* @param {Boolean} isFatal Marks the requirement as fatal. If such requirement will fail
* next requirements' checks will be skipped.
*/
-var Requirement = function (id, name, isFatal) {
+const Requirement = function (id, name, isFatal) {
this.id = id;
this.name = name;
this.installed = false;
@@ -84,15 +84,15 @@ var Requirement = function (id, name, isFatal) {
* @return Promise<Requirement[]> Array of requirements. Due to implementation, promise is always fulfilled.
*/
module.exports.check_all = function () {
- var requirements = [
+ const requirements = [
new Requirement('os', 'Apple OS X', true),
new Requirement('xcode', 'Xcode')
];
- var result = [];
- var fatalIsHit = false;
+ const result = [];
+ let fatalIsHit = false;
- var checkFns = [
+ const checkFns = [
module.exports.check_os,
module.exports.check_xcodebuild
];
@@ -104,7 +104,7 @@ module.exports.check_all = function () {
// we don't need to check others
if (fatalIsHit) return;
- var requirement = requirements[idx];
+ const requirement = requirements[idx];
return checkFn()
.then(function (version) {
requirement.installed = true;
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 7c67e7a..4245ecd 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -19,10 +19,10 @@
under the License.
*/
-var shell = require('shelljs');
-var path = require('path');
-var fs = require('fs');
-var ROOT = path.join(__dirname, '..', '..');
+const shell = require('shelljs');
+const path = require('path');
+const fs = require('fs');
+const ROOT = path.join(__dirname, '..', '..');
function updateSubprojectHelp () {
console.log('Updates the subproject path of the CordovaLib entry to point to this script\'s version of Cordova.');
@@ -30,7 +30,7 @@ function updateSubprojectHelp () {
}
function setShellFatal (value, func) {
- var oldVal = shell.config.fatal;
+ const oldVal = shell.config.fatal;
shell.config.fatal = value;
func();
shell.config.fatal = oldVal;
@@ -57,9 +57,9 @@ function copyJsAndCordovaLib (projectPath, projectName, use_shared) {
// like it should).
fs.symlinkSync(path.join(ROOT, 'CordovaLib'), path.join(projectPath, 'CordovaLib'));
} else {
- var r = path.join(projectPath, projectName);
- var srcLib = path.join(ROOT, 'CordovaLib');
- var dstLib = path.join(projectPath, 'CordovaLib');
+ const r = path.join(projectPath, projectName);
+ const srcLib = path.join(ROOT, 'CordovaLib');
+ const dstLib = path.join(projectPath, 'CordovaLib');
shell.mkdir('-p', path.join(dstLib, 'CordovaLib.xcodeproj'));
shell.cp('-f', path.join(r, '.gitignore'), projectPath);
shell.cp('-rf', path.join(srcLib, 'CordovaLib'), dstLib);
@@ -73,14 +73,14 @@ function copyJsAndCordovaLib (projectPath, projectName, use_shared) {
}
function copyScripts (projectPath) {
- var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
- var destScriptsDir = path.join(projectPath, 'cordova');
+ const srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
+ const destScriptsDir = path.join(projectPath, 'cordova');
// Delete old scripts directory.
shell.rm('-rf', destScriptsDir);
// Copy in the new ones.
- var binDir = path.join(ROOT, 'bin');
+ const binDir = path.join(ROOT, 'bin');
shell.cp('-r', srcScriptsDir, projectPath);
const nodeModulesDir = path.join(ROOT, 'node_modules');
@@ -102,9 +102,9 @@ function copyScripts (projectPath) {
}
function detectProjectName (projectDir) {
- var files = fs.readdirSync(projectDir);
- for (var i = 0; i < files.length; ++i) {
- var m = /(.*)\.xcodeproj$/.exec(files[i]);
+ const files = fs.readdirSync(projectDir);
+ for (let i = 0; i < files.length; ++i) {
+ const m = /(.*)\.xcodeproj$/.exec(files[i]);
if (m) {
return m[1];
}
@@ -117,7 +117,7 @@ function AbsParentPath (_path) {
}
function AbsProjectPath (relative_path) {
- var absolute_path = path.resolve(relative_path);
+ let absolute_path = path.resolve(relative_path);
if (/.pbxproj$/.test(absolute_path)) {
absolute_path = AbsParentPath(absolute_path);
} else if (!(/.xcodeproj$/.test(absolute_path))) {
@@ -145,10 +145,10 @@ function relpath (_path, start) {
exports.createProject = function (project_path, package_name, project_name, opts, events) {
package_name = package_name || 'my.cordova.project';
project_name = project_name || 'CordovaExample';
- var use_shared = !!opts.link;
- var bin_dir = path.join(ROOT, 'bin');
- var project_parent = path.dirname(project_path);
- var project_template_dir = opts.customTemplate || path.join(bin_dir, 'templates', 'project');
+ const use_shared = !!opts.link;
+ const bin_dir = path.join(ROOT, 'bin');
+ const project_parent = path.dirname(project_path);
+ const project_template_dir = opts.customTemplate || path.join(bin_dir, 'templates', 'project');
// check that project path doesn't exist
if (fs.existsSync(project_path)) {
@@ -168,12 +168,12 @@ exports.createProject = function (project_path, package_name, project_name, opts
shell.cp('-rf', path.join(project_template_dir, '__PROJECT_NAME__'), project_path);
shell.mv(path.join(project_path, '__PROJECT_NAME__'), path.join(project_path, project_name));
- var r = path.join(project_path, project_name);
+ const r = path.join(project_path, project_name);
shell.mv(path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name + '-Info.plist'));
shell.mv(path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name + '-Prefix.pch'));
shell.mv(path.join(r, 'gitignore'), path.join(r, '.gitignore'));
- var project_name_esc = project_name.replace(/&/g, '\\&');
+ const project_name_esc = project_name.replace(/&/g, '\\&');
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r + '.xcodeproj', 'project.pbxproj'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.h'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.m'));
@@ -196,7 +196,7 @@ exports.createProject = function (project_path, package_name, project_name, opts
};
exports.updateProject = function (projectPath, opts, events) {
- var projectName = detectProjectName(projectPath);
+ const projectName = detectProjectName(projectPath);
setShellFatal(true, function () {
copyJsAndCordovaLib(projectPath, projectName, opts.link);
copyScripts(projectPath);
@@ -206,8 +206,8 @@ exports.updateProject = function (projectPath, opts, events) {
};
function generateDoneMessage (type, link) {
- var pkg = require('../../package');
- var msg = 'OS X project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
+ const pkg = require('../../package');
+ let msg = 'OS X project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
if (link) {
msg += ' and has a linked CordovaLib';
}
@@ -220,24 +220,24 @@ function update_cordova_subproject (argv) {
throw new Error('Usage error for update_cordova_subproject');
}
- var projectPath = AbsProjectPath(argv[0]);
- var cordovaLibXcodePath;
+ const projectPath = AbsProjectPath(argv[0]);
+ let cordovaLibXcodePath;
if (argv.length < 2) {
cordovaLibXcodePath = path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj');
} else {
cordovaLibXcodePath = AbsProjectPath(argv[1]);
}
- var parentProjectPath = AbsParentPath(projectPath);
- var subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath);
- var REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/;
- var newLine;
- var lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj'));
- var found = false;
+ const parentProjectPath = AbsParentPath(projectPath);
+ let subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath);
+ const REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/;
+ let newLine;
+ let lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj'));
+ let found = false;
subprojectPath = subprojectPath.replace(/\\/g, '/');
lines = lines.split('\n');
- for (var i = 0; i < lines.length; ++i) {
+ for (let i = 0; i < lines.length; ++i) {
if (lines[i].match(REGEX)) {
found = true;
/* eslint-disable no-useless-escape */
@@ -252,8 +252,8 @@ function update_cordova_subproject (argv) {
// Patching pbxproj to replace copy www shell script with nodejs
// Don't forget to duplicate this in templates/__CLI__.xcodeproj/project.pbxproj and templates/__PROJECT_NAME__.xcodeproj/project.pbxproj on later changes
- var copyWwwSh = 'cordova\/lib\/copy-www-build-step\.sh';
- var copyWwwJs = 'NODEJS_PATH=\/usr\/local\/bin; NVM_NODE_PATH=~\/\.nvm\/versions\/node\/`nvm version 2>\/dev\/null`\/bin; N_NODE_PATH=`find \/usr\/local\/n\/versions\/node\/\* -maxdepth 0 -type d 2>\/dev\/null \| tail -1`\/bin; XCODE_NODE_PATH=`xcode-select --print-path`\/usr\/share\/xcs\/Node\/bin; PATH=\$NODEJS_PATH:\$NVM_NODE_PATH:\$N_NODE_PATH:\$XCODE_NODE_PATH:\$PATH && node cordova\/lib\/copy-www-build-step\.js';
+ const copyWwwSh = 'cordova\/lib\/copy-www-build-step\.sh';
+ const copyWwwJs = 'NODEJS_PATH=\/usr\/local\/bin; NVM_NODE_PATH=~\/\.nvm\/versions\/node\/`nvm version 2>\/dev\/null`\/bin; N_NODE_PATH=`find \/usr\/local\/n\/versions\/node\/\* -maxdepth 0 -type d 2>\/dev\/null \| tail -1`\/bin; XCODE_NODE_PATH=`xcode-select --print-path`\/usr\/share\/xcs\/Node\/bin; PATH=\$NODEJS_PATH:\$NVM_NODE_PATH:\$N_NODE_PATH:\$XCODE_NODE_PATH:\$PATH && node cordova\/lib\/copy-www-build-step\.js';
shell.sed('-i', copyWwwSh, copyWwwJs, path.join(projectPath, 'project.pbxproj'));
/* eslint-enable no-useless-escape */
diff --git a/bin/lib/versions.js b/bin/lib/versions.js
index 9462d56..1a7d76b 100755
--- a/bin/lib/versions.js
+++ b/bin/lib/versions.js
@@ -19,7 +19,7 @@
under the License.
*/
-var child_process = require('child_process');
+const child_process = require('child_process');
exports.get_apple_osx_version = function () {
return new Promise((resolve, reject) => {
@@ -31,11 +31,11 @@ exports.get_apple_osx_version = function () {
}
});
}).then(function (output) {
- var regex = /[0-9]*\.[0-9]*/;
- var versions = [];
- var regexOSX = /^OS X \d+/;
+ const regex = /[0-9]*\.[0-9]*/;
+ const versions = [];
+ const regexOSX = /^OS X \d+/;
output = output.split('\n');
- for (var i = 0; i < output.length; i++) {
+ for (let i = 0; i < output.length; i++) {
if (output[i].trim().match(regexOSX)) {
versions[versions.length] = parseFloat(output[i].match(regex)[0]);
}
@@ -48,7 +48,7 @@ exports.get_apple_osx_version = function () {
exports.get_apple_xcode_version = function () {
return new Promise((resolve, reject) => {
child_process.exec('xcodebuild -version', function (error, stdout, stderr) {
- var versionMatch = /Xcode (.*)/.exec(stdout);
+ const versionMatch = /Xcode (.*)/.exec(stdout);
if (error || !versionMatch) {
reject(stderr);
} else {
@@ -83,7 +83,7 @@ exports.compareVersions = function (version1, version2) {
function parseVer (version) {
return version.split('.').map(function (value) {
// try to convert version segment to Number
- var parsed = Number(value);
+ const parsed = Number(value);
// Number constructor is strict enough and will return NaN
// if conversion fails. In this case we won't be able to compare versions properly
if (isNaN(parsed)) {
@@ -92,14 +92,14 @@ exports.compareVersions = function (version1, version2) {
return parsed;
});
}
- var parsedVer1 = parseVer(version1);
- var parsedVer2 = parseVer(version2);
+ const parsedVer1 = parseVer(version1);
+ const parsedVer2 = parseVer(version2);
// Compare corresponding segments of each version
- for (var i = 0; i < Math.max(parsedVer1.length, parsedVer2.length); i++) {
+ for (let i = 0; i < Math.max(parsedVer1.length, parsedVer2.length); i++) {
// if segment is not specified, assume that it is 0
// E.g. 3.1 is equal to 3.1.0
- var ret = (parsedVer1[i] || 0) - (parsedVer2[i] || 0);
+ const ret = (parsedVer1[i] || 0) - (parsedVer2[i] || 0);
// if segments are not equal, we're finished
if (ret !== 0) return ret;
}
diff --git a/bin/templates/scripts/cordova/Api.js b/bin/templates/scripts/cordova/Api.js
index 54fc74b..00250a7 100644
--- a/bin/templates/scripts/cordova/Api.js
+++ b/bin/templates/scripts/cordova/Api.js
@@ -17,13 +17,13 @@
under the License.
*/
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var PluginManager = require('cordova-common').PluginManager;
-var projectFile = require('./lib/projectFile');
-var CordovaError = require('cordova-common').CordovaError;
-var ConsoleLogger = require('./lib/ConsoleLogger');
+const PluginManager = require('cordova-common').PluginManager;
+const projectFile = require('./lib/projectFile');
+const CordovaError = require('cordova-common').CordovaError;
+const ConsoleLogger = require('./lib/ConsoleLogger');
/**
* Creates a new PlatformApi instance.
@@ -45,8 +45,8 @@ function Api (platform, platformRootDir, events) {
// NOTE: trick to share one EventEmitter instance across all js code
require('cordova-common').events = this.events;
- var xcodeProjDir;
- var xcodeCordovaProj;
+ let xcodeProjDir;
+ let xcodeCordovaProj;
try {
xcodeProjDir = fs.readdirSync(this.root).filter(function (e) { return e.match(/\.xcodeproj$/i); })[0];
@@ -54,7 +54,7 @@ function Api (platform, platformRootDir, events) {
throw new CordovaError('The provided path "' + this.root + '" is not a Cordova iOS project.');
}
- var cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep) + 1, xcodeProjDir.indexOf('.xcodeproj'));
+ const cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep) + 1, xcodeProjDir.indexOf('.xcodeproj'));
xcodeCordovaProj = path.join(this.root, cordovaProjName);
} catch (e) {
throw new CordovaError('The provided path "' + this.root + '" is not a Cordova iOS project.');
@@ -100,7 +100,7 @@ Api.createPlatform = function (destination, config, options, events) {
.then(function () {
// after platform is created we return Api instance based on new Api.js location
// This is required to correctly resolve paths in the future api calls
- var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
+ const PlatformApi = require(path.resolve(destination, 'cordova/Api'));
return new PlatformApi('osx', destination, events);
});
};
@@ -125,7 +125,7 @@ Api.updatePlatform = function (destination, options, events) {
return require('../../../lib/create')
.updateProject(destination, options, events || ConsoleLogger.get())
.then(function () {
- var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
+ const PlatformApi = require(path.resolve(destination, 'cordova/Api'));
return new PlatformApi('android', destination, events);
});
};
@@ -137,7 +137,7 @@ Api.updatePlatform = function (destination, options, events) {
* platform's file structure and other properties of platform.
*/
Api.prototype.getPlatformInfo = function () {
- var result = {};
+ const result = {};
result.locations = this.locations;
result.root = this.root;
result.name = this.platform;
@@ -183,7 +183,7 @@ Api.prototype.prepare = function (cordovaProject) {
* CordovaError instance.
*/
Api.prototype.addPlugin = function (plugin, installOptions) {
- var xcodeproj = projectFile.parse(this.locations);
+ const xcodeproj = projectFile.parse(this.locations);
return PluginManager.get(this.platform, this.locations, xcodeproj).addPlugin(plugin, installOptions);
};
@@ -201,7 +201,7 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
* CordovaError instance.
*/
Api.prototype.removePlugin = function (plugin, uninstallOptions) {
- var xcodeproj = projectFile.parse(this.locations);
+ const xcodeproj = projectFile.parse(this.locations);
return PluginManager.get(this.platform, this.locations, xcodeproj).removePlugin(plugin, uninstallOptions);
};
@@ -238,7 +238,7 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
* CordovaError instance.
*/
Api.prototype.build = function (buildOptions) {
- var self = this;
+ const self = this;
return require('./lib/check_reqs').run()
.then(function () {
return require('./lib/build').run.call(self, buildOptions);
@@ -258,7 +258,7 @@ Api.prototype.build = function (buildOptions) {
* successfully, or rejected with CordovaError.
*/
Api.prototype.run = function (runOptions) {
- var self = this;
+ const self = this;
return require('./lib/check_reqs').run()
.then(function () {
return require('./lib/run').run.call(self, runOptions);
@@ -272,7 +272,7 @@ Api.prototype.run = function (runOptions) {
* CordovaError.
*/
Api.prototype.clean = function (cleanOptions) {
- var self = this;
+ const self = this;
return require('./lib/check_reqs').run()
.then(function () {
return require('./lib/clean').run.call(self, cleanOptions);
diff --git a/bin/templates/scripts/cordova/build b/bin/templates/scripts/cordova/build
index a6bfef5..6eb357c 100755
--- a/bin/templates/scripts/cordova/build
+++ b/bin/templates/scripts/cordova/build
@@ -19,9 +19,9 @@
under the License.
*/
-var args = process.argv;
-var Api = require('./Api');
-var nopt = require('nopt');
+const args = process.argv;
+const Api = require('./Api');
+const nopt = require('nopt');
// Support basic help commands
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
@@ -30,7 +30,7 @@ if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >=
}
// Parse arguments
-var buildOpts = nopt({
+const buildOpts = nopt({
verbose: Boolean,
silent: Boolean,
debug: Boolean,
@@ -48,7 +48,7 @@ buildOpts.argv = buildOpts.argv.remain;
new Api().build(buildOpts).then(function () {
console.log('** BUILD SUCCEEDED **');
}, function (err) {
- var errorMessage = (err && err.stack) ? err.stack : err;
+ const errorMessage = (err && err.stack) ? err.stack : err;
console.error(errorMessage);
process.exit(2);
});
diff --git a/bin/templates/scripts/cordova/clean b/bin/templates/scripts/cordova/clean
index 5d711c4..f63e035 100755
--- a/bin/templates/scripts/cordova/clean
+++ b/bin/templates/scripts/cordova/clean
@@ -19,7 +19,7 @@
under the License.
*/
-var Api = require('./Api');
+const Api = require('./Api');
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
console.log('Cleans the project directory.');
diff --git a/bin/templates/scripts/cordova/lib/ConsoleLogger.js b/bin/templates/scripts/cordova/lib/ConsoleLogger.js
index d190206..5d2fa38 100644
--- a/bin/templates/scripts/cordova/lib/ConsoleLogger.js
+++ b/bin/templates/scripts/cordova/lib/ConsoleLogger.js
@@ -17,10 +17,10 @@
under the License.
*/
-var loggerInstance;
-var util = require('util');
-var EventEmitter = require('events').EventEmitter;
-var CordovaError = require('cordova-common').CordovaError;
+let loggerInstance;
+const util = require('util');
+const EventEmitter = require('events').EventEmitter;
+const CordovaError = require('cordova-common').CordovaError;
/**
* @class ConsoleLogger
@@ -36,7 +36,7 @@ var CordovaError = require('cordova-common').CordovaError;
function ConsoleLogger () {
EventEmitter.call(this);
- var isVerbose = process.argv.indexOf('-d') >= 0 || process.argv.indexOf('--verbose') >= 0;
+ const isVerbose = process.argv.indexOf('-d') >= 0 || process.argv.indexOf('--verbose') >= 0;
// For CordovaError print only the message without stack trace unless we
// are in a verbose mode.
process.on('uncaughtException', function (err) {
diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js
index 577b6cd..e438376 100644
--- a/bin/templates/scripts/cordova/lib/build.js
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -18,16 +18,16 @@
*/
const { promisify } = require('util');
-var path = require('path');
-var shell = require('shelljs');
-var spawn = require('./spawn');
-var check_reqs = require('./check_reqs');
-var fs = require('fs');
+const path = require('path');
+const shell = require('shelljs');
+const spawn = require('./spawn');
+const check_reqs = require('./check_reqs');
+const fs = require('fs');
-var events = require('cordova-common').events;
+const events = require('cordova-common').events;
-var projectPath = path.join(__dirname, '..', '..');
-var projectName = null;
+const projectPath = path.join(__dirname, '..', '..');
+let projectName = null;
module.exports.run = function (buildOpts) {
buildOpts = buildOpts || {};
@@ -45,10 +45,10 @@ module.exports.run = function (buildOpts) {
return Promise.reject('Build config file does not exist:' + buildOpts.buildConfig);
}
events.emit('log', 'Reading build config file:', path.resolve(buildOpts.buildConfig));
- var buildConfig = JSON.parse(fs.readFileSync(buildOpts.buildConfig, 'utf-8'));
+ const buildConfig = JSON.parse(fs.readFileSync(buildOpts.buildConfig, 'utf-8'));
if (buildConfig.osx) {
- var buildType = buildOpts.release ? 'release' : 'debug';
- var config = buildConfig.osx[buildType];
+ const buildType = buildOpts.release ? 'release' : 'debug';
+ const config = buildConfig.osx[buildType];
if (config) {
['codeSignIdentity', 'codeSignResourceRules', 'provisioningProfile'].forEach(
function (key) {
@@ -62,7 +62,7 @@ module.exports.run = function (buildOpts) {
return findXCodeProjectIn(projectPath);
}).then(function (name) {
projectName = name;
- var extraConfig = '';
+ let extraConfig = '';
if (buildOpts.codeSignIdentity) {
extraConfig += 'CODE_SIGN_IDENTITY = ' + buildOpts.codeSignIdentity + '\n';
}
@@ -74,12 +74,12 @@ module.exports.run = function (buildOpts) {
}
return promisify(fs.writeFile)(path.join(__dirname, '..', 'build-extras.xcconfig'), extraConfig, 'utf-8');
}).then(function () {
- var configuration = buildOpts.release ? 'Release' : 'Debug';
+ const configuration = buildOpts.release ? 'Release' : 'Debug';
events.emit('log', 'Building project : ' + path.join(projectPath, projectName + '.xcodeproj'));
events.emit('log', '\tConfiguration : ' + configuration);
- var xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration);
+ const xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration);
return spawn('xcodebuild', xcodebuildArgs, projectPath);
}).then(function () {
if (buildOpts.noSign) {
@@ -110,7 +110,7 @@ module.exports.run = function (buildOpts) {
*/
function findXCodeProjectIn (projectPath) {
// 'Searching for Xcode project in ' + projectPath);
- var xcodeProjFiles = shell.ls(projectPath).filter(function (name) {
+ const xcodeProjFiles = shell.ls(projectPath).filter(function (name) {
return path.extname(name) === '.xcodeproj';
});
@@ -122,7 +122,7 @@ function findXCodeProjectIn (projectPath) {
projectPath + '\nUsing first one');
}
- var projectName = path.basename(xcodeProjFiles[0], '.xcodeproj');
+ const projectName = path.basename(xcodeProjFiles[0], '.xcodeproj');
return Promise.resolve(projectName);
}
diff --git a/bin/templates/scripts/cordova/lib/clean.js b/bin/templates/scripts/cordova/lib/clean.js
index 391e8ce..579c1ec 100644
--- a/bin/templates/scripts/cordova/lib/clean.js
+++ b/bin/templates/scripts/cordova/lib/clean.js
@@ -17,14 +17,14 @@
* under the License.
*/
-var path = require('path');
-var shell = require('shelljs');
-var spawn = require('./spawn');
+const path = require('path');
+const shell = require('shelljs');
+const spawn = require('./spawn');
-var projectPath = path.join(__dirname, '..', '..');
+const projectPath = path.join(__dirname, '..', '..');
module.exports.run = function () {
- var projectName = shell.ls(projectPath).filter(function (name) {
+ const projectName = shell.ls(projectPath).filter(function (name) {
return path.extname(name) === '.xcodeproj';
})[0];
diff --git a/bin/templates/scripts/cordova/lib/configMunger.js b/bin/templates/scripts/cordova/lib/configMunger.js
index 2f0b7f5..1a4f7a0 100644
--- a/bin/templates/scripts/cordova/lib/configMunger.js
+++ b/bin/templates/scripts/cordova/lib/configMunger.js
@@ -19,12 +19,12 @@
/* jshint node: true */
-var PlatformJson = require('cordova-common').PlatformJson;
-var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
-var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
+const PlatformJson = require('cordova-common').PlatformJson;
+const PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
+const PluginInfoProvider = require('cordova-common').PluginInfoProvider;
// shared PlatformMunger instance
-var _instance = null;
+let _instance = null;
module.exports = {
diff --git a/bin/templates/scripts/cordova/lib/copy-www-build-step.js b/bin/templates/scripts/cordova/lib/copy-www-build-step.js
index 04c0e3e..c65db1f 100644
--- a/bin/templates/scripts/cordova/lib/copy-www-build-step.js
+++ b/bin/templates/scripts/cordova/lib/copy-www-build-step.js
@@ -24,17 +24,17 @@
// This script should not be called directly.
// It is called as a build step from Xcode.
-var BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR;
-var FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME;
-var COPY_HIDDEN = process.env.COPY_HIDDEN;
-var PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH;
+const BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR;
+const FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME;
+const COPY_HIDDEN = process.env.COPY_HIDDEN;
+const PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH;
-var path = require('path');
-var fs = require('fs');
-var shell = require('shelljs');
-var srcDir = 'www';
-var dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME, 'Contents', 'Resources');
-var dstWwwDir = path.join(dstDir, 'www');
+const path = require('path');
+const fs = require('fs');
+const shell = require('shelljs');
+const srcDir = 'www';
+const dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME, 'Contents', 'Resources');
+const dstWwwDir = path.join(dstDir, 'www');
if (!BUILT_PRODUCTS_DIR) {
console.error('The script is meant to be run as an Xcode build step and relies on env variables set by Xcode.');
@@ -56,7 +56,7 @@ shell.rm('-rf', path.join(dstDir, 'PkgInfo'));
shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision'));
// Copy www dir recursively
-var code;
+let code;
if (COPY_HIDDEN) {
code = shell.exec('rsync -Lra "' + srcDir + '" "' + dstDir + '"').code;
} else {
diff --git a/bin/templates/scripts/cordova/lib/plugman/Plugman.js b/bin/templates/scripts/cordova/lib/plugman/Plugman.js
index e3dfc78..3d9df43 100644
--- a/bin/templates/scripts/cordova/lib/plugman/Plugman.js
+++ b/bin/templates/scripts/cordova/lib/plugman/Plugman.js
@@ -17,16 +17,16 @@
under the License.
*/
-var path = require('path');
-var fs = require('fs');
-var shell = require('shelljs');
+const path = require('path');
+const fs = require('fs');
+const shell = require('shelljs');
-var CordovaError = require('cordova-common').CordovaError;
-var ActionStack = require('cordova-common').ActionStack;
+const CordovaError = require('cordova-common').CordovaError;
+const ActionStack = require('cordova-common').ActionStack;
-var configMunger = require('../configMunger');
-var projectFile = require('../projectFile');
-var pluginHandlers = require('./pluginHandlers');
+const configMunger = require('../configMunger');
+const projectFile = require('../projectFile');
+const pluginHandlers = require('./pluginHandlers');
function Plugman (locations, events) {
this.locations = locations;
@@ -38,7 +38,7 @@ function Plugman (locations, events) {
}
// shared Plugman instance
-var _instance = null;
+let _instance = null;
Plugman.get = function (locations, events) {
if (!_instance) {
@@ -57,10 +57,10 @@ Plugman.prototype.addPlugin = function (plugin, installOptions) {
installOptions = installOptions || {};
installOptions.variables = installOptions.variables || {};
- var self = this;
- var actions = new ActionStack();
+ const self = this;
+ const actions = new ActionStack();
- var project = projectFile.parse(this.locations);
+ const project = projectFile.parse(this.locations);
// gather all files needs to be handled during install
plugin.getFilesAndFrameworks(this.platform).concat(plugin.getAssets(this.platform)).concat(plugin.getJsModules(this.platform)).forEach(function (item) {
@@ -86,7 +86,7 @@ Plugman.prototype.addPlugin = function (plugin, installOptions) {
.add_plugin_changes(plugin, installOptions.variables, /* is_top_level= */true, /* should_increment= */true)
.save_all();
- var targetDir = installOptions.usePlatformWww
+ const targetDir = installOptions.usePlatformWww
? self.locations.platformWww
: self.locations.www;
@@ -97,9 +97,9 @@ Plugman.prototype.addPlugin = function (plugin, installOptions) {
Plugman.prototype.removePlugin = function (plugin, uninstallOptions) {
if (!plugin || plugin.constructor.name !== 'PluginInfo') { return Promise.reject(new CordovaError('The parameter is incorrect. The first parameter to addPlugin should be a PluginInfo instance')); }
- var self = this;
- var actions = new ActionStack();
- var project = projectFile.parse(this.locations);
+ const self = this;
+ const actions = new ActionStack();
+ const project = projectFile.parse(this.locations);
// queue up plugin files
plugin.getFilesAndFrameworks(this.platform).concat(plugin.getAssets(this.platform)).concat(plugin.getJsModules(this.platform)).forEach(function (item) {
@@ -120,7 +120,7 @@ Plugman.prototype.removePlugin = function (plugin, uninstallOptions) {
.remove_plugin_changes(plugin, /* is_top_level= */true)
.save_all();
- var targetDir = uninstallOptions.usePlatformWww
+ const targetDir = uninstallOptions.usePlatformWww
? self.locations.platformWww
: self.locations.www;
@@ -138,17 +138,17 @@ Plugman.prototype.removePlugin = function (plugin, uninstallOptions) {
* should be written to.
*/
Plugman.prototype._addModulesInfo = function (plugin, targetDir) {
- var installedModules = this._platformJson.root.modules || [];
+ const installedModules = this._platformJson.root.modules || [];
- var installedPaths = installedModules.map(function (installedModule) {
+ const installedPaths = installedModules.map(function (installedModule) {
return installedModule.file;
});
- var modulesToInstall = plugin.getJsModules(this.platform).filter(function (moduleToInstall) {
+ const modulesToInstall = plugin.getJsModules(this.platform).filter(function (moduleToInstall) {
return installedPaths.indexOf(moduleToInstall.file) === -1;
}).map(function (moduleToInstall) {
- var moduleName = plugin.id + '.' + (moduleToInstall.name || moduleToInstall.src.match(/([^\/]+)\.js/)[1]); /* eslint no-useless-escape : 0 */
- var obj = {
+ const moduleName = plugin.id + '.' + (moduleToInstall.name || moduleToInstall.src.match(/([^\/]+)\.js/)[1]); /* eslint no-useless-escape : 0 */
+ const obj = {
file: ['plugins', plugin.id, moduleToInstall.src].join('/'),
id: moduleName,
pluginId: plugin.id
@@ -180,14 +180,14 @@ Plugman.prototype._addModulesInfo = function (plugin, targetDir) {
* directories.
*/
Plugman.prototype._writePluginModules = function (targetDir) {
- var self = this;
+ const self = this;
// Write out moduleObjects as JSON wrapped in a cordova module to cordova_plugins.js
- var final_contents = 'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {\n';
+ let final_contents = 'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {\n';
final_contents += 'module.exports = ' + JSON.stringify(this._platformJson.root.modules, null, ' ') + ';\n';
final_contents += 'module.exports.metadata = \n';
final_contents += '// TOP OF METADATA\n';
- var pluginMetadata = Object.keys(this._platformJson.root.installed_plugins).reduce(function (metadata, plugin) {
+ const pluginMetadata = Object.keys(this._platformJson.root.installed_plugins).reduce(function (metadata, plugin) {
metadata[plugin] = self._platformJson.root.installed_plugins[plugin].version;
return metadata;
}, {});
@@ -210,12 +210,12 @@ Plugman.prototype._writePluginModules = function (targetDir) {
* should be written to.
*/
Plugman.prototype._removeModulesInfo = function (plugin, targetDir) {
- var installedModules = this._platformJson.root.modules || [];
- var modulesToRemove = plugin.getJsModules(this.platform).map(function (jsModule) {
+ const installedModules = this._platformJson.root.modules || [];
+ const modulesToRemove = plugin.getJsModules(this.platform).map(function (jsModule) {
return ['plugins', plugin.id, jsModule.src].join('/');
});
- var updatedModules = installedModules.filter(function (installedModule) {
+ const updatedModules = installedModules.filter(function (installedModule) {
return (modulesToRemove.indexOf(installedModule.file) === -1);
});
diff --git a/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js b/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
index 32196e3..d42afd7 100644
--- a/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
+++ b/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
@@ -15,20 +15,20 @@
under the License.
*/
-var fs = require('fs');
-var path = require('path');
-var shell = require('shelljs');
-var events = require('cordova-common').events;
-var CordovaError = require('cordova-common').CordovaError;
+const fs = require('fs');
+const path = require('path');
+const shell = require('shelljs');
+const events = require('cordova-common').events;
+const CordovaError = require('cordova-common').CordovaError;
// These frameworks are required by cordova-osx by default. We should never add/remove them.
-var keep_these_frameworks = [
+const keep_these_frameworks = [
'MobileCoreServices.framework',
'CoreGraphics.framework',
'AssetsLibrary.framework'
];
-var handlers = {
+const handlers = {
'source-file': {
install: function (obj, plugin, project, options) {
installHelper('source-file', obj, plugin.dir, project.projectDir, plugin.id, options, project);
@@ -47,25 +47,25 @@ var handlers = {
},
'resource-file': {
install: function (obj, plugin, project, options) {
- var src = obj.src;
- var srcFile = path.resolve(plugin.dir, src);
- var destFile = path.resolve(project.resources_dir, path.basename(src));
+ const src = obj.src;
+ const srcFile = path.resolve(plugin.dir, src);
+ const destFile = path.resolve(project.resources_dir, path.basename(src));
if (!fs.existsSync(srcFile)) throw new CordovaError('cannot find "' + srcFile + '" osx <resource-file>');
if (fs.existsSync(destFile)) throw new CordovaError('target destination "' + destFile + '" already exists');
project.xcode.addResourceFile(path.join('Resources', path.basename(src)));
shell.cp('-R', srcFile, project.resources_dir);
},
uninstall: function (obj, plugin, project, options) {
- var src = obj.src;
- var destFile = path.resolve(project.resources_dir, path.basename(src));
+ const src = obj.src;
+ const destFile = path.resolve(project.resources_dir, path.basename(src));
project.xcode.removeResourceFile(path.join('Resources', path.basename(src)));
shell.rm('-rf', destFile);
}
},
framework: { // CB-5238 custom frameworks only
install: function (obj, plugin, project, options) {
- var src = obj.src;
- var custom = obj.custom;
+ const src = obj.src;
+ const custom = obj.custom;
if (!custom) {
if (keep_these_frameworks.indexOf(src) < 0) {
@@ -75,20 +75,20 @@ var handlers = {
return;
}
- var srcFile = path.resolve(plugin.dir, src);
- var targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
+ const srcFile = path.resolve(plugin.dir, src);
+ const targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
if (!fs.existsSync(srcFile)) throw new CordovaError('cannot find "' + srcFile + '" osx <framework>');
if (fs.existsSync(targetDir)) throw new CordovaError('target destination "' + targetDir + '" already exists');
shell.mkdir('-p', path.dirname(targetDir));
shell.cp('-R', srcFile, path.dirname(targetDir)); // frameworks are directories
- var project_relative = path.relative(project.projectDir, targetDir);
- var pbxFile = project.xcode.addFramework(project_relative, { customFramework: true });
+ const project_relative = path.relative(project.projectDir, targetDir);
+ const pbxFile = project.xcode.addFramework(project_relative, { customFramework: true });
if (pbxFile) {
project.xcode.addToPbxEmbedFrameworksBuildPhase(pbxFile);
}
},
uninstall: function (obj, plugin, project, options) {
- var src = obj.src;
+ const src = obj.src;
if (!obj.custom) {
if (keep_these_frameworks.indexOf(src) < 0) {
@@ -103,8 +103,8 @@ var handlers = {
return;
}
- var targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
- var pbxFile = project.xcode.removeFramework(targetDir, { customFramework: true });
+ const targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
+ const pbxFile = project.xcode.removeFramework(targetDir, { customFramework: true });
if (pbxFile) {
project.xcode.removeFromPbxEmbedFrameworksBuildPhase(pbxFile);
}
@@ -128,18 +128,18 @@ var handlers = {
throw new CordovaError('<asset> tag without required "target" attribute');
}
- var www = options.usePlatformWww ? project.platformWww : project.www;
+ const www = options.usePlatformWww ? project.platformWww : project.www;
copyFile(plugin.dir, obj.src, www, obj.target);
},
uninstall: function (obj, plugin, project, options) {
- var target = obj.target;
+ const target = obj.target;
if (!target) {
throw new Error('<asset> tag without required "target" attribute');
}
- var www = options.usePlatformWww ? project.platformWww : project.www;
+ const www = options.usePlatformWww ? project.platformWww : project.www;
removeFile(www, target);
removeFileF(path.resolve(project.www, 'plugins', plugin.id));
@@ -148,24 +148,24 @@ var handlers = {
'js-module': {
install: function (obj, plugin, project, options) {
// Copy the plugin's files into the www directory.
- var moduleSource = path.resolve(plugin.dir, obj.src);
- var moduleName = plugin.id + '.' + (obj.name || path.parse(obj.src).name);
+ const moduleSource = path.resolve(plugin.dir, obj.src);
+ const moduleName = plugin.id + '.' + (obj.name || path.parse(obj.src).name);
// Read in the file, prepend the cordova.define, and write it back out.
- var scriptContent = fs.readFileSync(moduleSource, 'utf-8').replace(/^\ufeff/, ''); // Window BOM
+ let scriptContent = fs.readFileSync(moduleSource, 'utf-8').replace(/^\ufeff/, ''); // Window BOM
if (moduleSource.match(/.*\.json$/)) {
scriptContent = 'module.exports = ' + scriptContent;
}
scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) {\n' + scriptContent + '\n});\n';
- var www = options.usePlatformWww ? project.platformWww : project.www;
- var moduleDestination = path.resolve(www, 'plugins', plugin.id, obj.src);
+ const www = options.usePlatformWww ? project.platformWww : project.www;
+ const moduleDestination = path.resolve(www, 'plugins', plugin.id, obj.src);
shell.mkdir('-p', path.dirname(moduleDestination));
fs.writeFileSync(moduleDestination, scriptContent, 'utf-8');
},
uninstall: function (obj, plugin, project, options) {
- var pluginRelativePath = path.join('plugins', plugin.id, obj.src);
- var www = options.usePlatformWww ? project.platformWww : project.www;
+ const pluginRelativePath = path.join('plugins', plugin.id, obj.src);
+ const www = options.usePlatformWww ? project.platformWww : project.www;
removeFileAndParents(www, pluginRelativePath);
}
}
@@ -188,14 +188,14 @@ module.exports.getUninstaller = function (type) {
};
function installHelper (type, obj, plugin_dir, project_dir, plugin_id, options, project) {
- var srcFile = path.resolve(plugin_dir, obj.src);
- var targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
- var destFile = path.join(targetDir, path.basename(obj.src));
+ const srcFile = path.resolve(plugin_dir, obj.src);
+ const targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
+ const destFile = path.join(targetDir, path.basename(obj.src));
- var project_ref;
- var link = !!(options && options.link);
+ let project_ref;
+ const link = !!(options && options.link);
if (link) {
- var trueSrc = fs.realpathSync(srcFile);
+ const trueSrc = fs.realpathSync(srcFile);
// Create a symlink in the expected place, so that uninstall can use it.
copyNewFile(plugin_dir, trueSrc, project_dir, destFile, link);
@@ -212,8 +212,8 @@ function installHelper (type, obj, plugin_dir, project_dir, plugin_id, options,
if (type === 'header-file') {
project.xcode.addHeaderFile(project_ref);
} else if (obj.framework) {
- var opt = { weak: obj.weak };
- var project_relative = path.join(path.basename(project.xcode_path), project_ref);
+ const opt = { weak: obj.weak };
+ const project_relative = path.join(path.basename(project.xcode_path), project_ref);
project.xcode.addFramework(project_relative, opt);
project.xcode.addToLibrarySearchPaths({ path: project_ref });
} else {
@@ -222,13 +222,13 @@ function installHelper (type, obj, plugin_dir, project_dir, plugin_id, options,
}
function uninstallHelper (type, obj, project_dir, plugin_id, options, project) {
- var targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
- var destFile = path.join(targetDir, path.basename(obj.src));
+ const targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
+ const destFile = path.join(targetDir, path.basename(obj.src));
- var project_ref;
- var link = !!(options && options.link);
+ let project_ref;
+ const link = !!(options && options.link);
if (link) {
- var trueSrc = fs.readlinkSync(destFile);
+ const trueSrc = fs.readlinkSync(destFile);
project_ref = 'Plugins/' + fixPathSep(path.relative(fs.realpathSync(project.plugins_dir), trueSrc));
} else {
project_ref = 'Plugins/' + fixPathSep(path.relative(project.plugins_dir, destFile));
@@ -239,7 +239,7 @@ function uninstallHelper (type, obj, project_dir, plugin_id, options, project) {
if (type === 'header-file') {
project.xcode.removeHeaderFile(project_ref);
} else if (obj.framework) {
- var project_relative = path.join(path.basename(project.xcode_path), project_ref);
+ const project_relative = path.join(path.basename(project.xcode_path), project_ref);
project.xcode.removeFramework(project_relative);
project.xcode.removeFromLibrarySearchPaths({ path: project_ref });
} else {
@@ -247,7 +247,7 @@ function uninstallHelper (type, obj, project_dir, plugin_id, options, project) {
}
}
-var pathSepFix = new RegExp(path.sep.replace(/\\/, '\\\\'), 'g');
+const pathSepFix = new RegExp(path.sep.replace(/\\/, '\\\\'), 'g');
function fixPathSep (file) {
return file.replace(pathSepFix, '/');
}
@@ -257,8 +257,8 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
if (!fs.existsSync(src)) throw new CordovaError('"' + src + '" not found!');
// check that src path is inside plugin directory
- var real_path = fs.realpathSync(src);
- var real_plugin_path = fs.realpathSync(plugin_dir);
+ const real_path = fs.realpathSync(src);
+ const real_plugin_path = fs.realpathSync(plugin_dir);
if (real_path.indexOf(real_plugin_path) !== 0) { throw new CordovaError('"' + src + '" not located within plugin!'); }
dest = path.resolve(project_dir, dest);
@@ -280,7 +280,7 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
// Same as copy file but throws error if target exists
function copyNewFile (plugin_dir, src, project_dir, dest, link) {
- var target_path = path.resolve(project_dir, dest);
+ const target_path = path.resolve(project_dir, dest);
if (fs.existsSync(target_path)) { throw new CordovaError('"' + target_path + '" already exists!'); }
copyFile(plugin_dir, src, project_dir, dest, !!link);
@@ -288,7 +288,7 @@ function copyNewFile (plugin_dir, src, project_dir, dest, link) {
// checks if file exists and then deletes. Error if doesn't exist
function removeFile (project_dir, src) {
- var file = path.resolve(project_dir, src);
+ const file = path.resolve(project_dir, src);
shell.rm('-Rf', file);
}
@@ -299,13 +299,13 @@ function removeFileF (file) {
function removeFileAndParents (baseDir, destFile, stopper) {
stopper = stopper || '.';
- var file = path.resolve(baseDir, destFile);
+ const file = path.resolve(baseDir, destFile);
if (!fs.existsSync(file)) return;
removeFileF(file);
// check if directory is empty
- var curDir = path.dirname(file);
+ let curDir = path.dirname(file);
while (curDir !== path.resolve(baseDir, stopper)) {
if (fs.existsSync(curDir) && fs.readdirSync(curDir).length === 0) {
diff --git a/bin/templates/scripts/cordova/lib/prepare.js b/bin/templates/scripts/cordova/lib/prepare.js
index 2844172..67a93b3 100644
--- a/bin/templates/scripts/cordova/lib/prepare.js
+++ b/bin/templates/scripts/cordova/lib/prepare.js
@@ -17,23 +17,23 @@
under the License.
*/
-var fs = require('fs');
-var path = require('path');
-var shell = require('shelljs');
-var xcode = require('xcode');
-var unorm = require('unorm');
-var plist = require('plist');
-var URL = require('url');
-var events = require('cordova-common').events;
-var xmlHelpers = require('cordova-common').xmlHelpers;
-var ConfigParser = require('cordova-common').ConfigParser;
-var CordovaError = require('cordova-common').CordovaError;
-var configMunger = require('./configMunger');
+const fs = require('fs');
+const path = require('path');
+const shell = require('shelljs');
+const xcode = require('xcode');
+const unorm = require('unorm');
+const plist = require('plist');
+const URL = require('url');
+const events = require('cordova-common').events;
+const xmlHelpers = require('cordova-common').xmlHelpers;
+const ConfigParser = require('cordova-common').ConfigParser;
+const CordovaError = require('cordova-common').CordovaError;
+const configMunger = require('./configMunger');
/* jshint sub:true */
module.exports.prepare = function (cordovaProject) {
- var self = this;
+ const self = this;
this._config = updateConfigFile(cordovaProject.projectConfig,
configMunger.get(this.locations.root), this.locations);
@@ -75,7 +75,7 @@ function updateConfigFile (sourceConfig, configMunger, locations) {
configMunger.reapply_global_munge().save_all();
// Merge changes from app's config.xml into platform's one
- var config = new ConfigParser(locations.configXml);
+ const config = new ConfigParser(locations.configXml);
xmlHelpers.mergeXml(sourceConfig.doc.getroot(),
config.doc.getroot(), 'osx', /* clobber= */true);
@@ -101,10 +101,10 @@ function updateWww (cordovaProject, destinations) {
shell.cp('-rf', path.join(destinations.platformWww, '*'), destinations.www);
// If project contains 'merges' for our platform, use them as another overrides
- var merges_path = path.join(cordovaProject.root, 'merges', 'osx');
+ const merges_path = path.join(cordovaProject.root, 'merges', 'osx');
if (fs.existsSync(merges_path)) {
events.emit('verbose', 'Found "merges" for osx platform. Copying over existing "www" files.');
- var overrides = path.join(merges_path, '*');
+ const overrides = path.join(merges_path, '*');
shell.cp('-rf', overrides, destinations.www);
}
}
@@ -120,38 +120,38 @@ function updateProject (platformConfig, locations) {
// CB-6992 it is necessary to normalize characters
// because node and shell scripts handles unicode symbols differently
// We need to normalize the name to NFD form since OSX uses NFD unicode form
- var name = unorm.nfd(platformConfig.name());
- var pkg = platformConfig.ios_CFBundleIdentifier() || platformConfig.packageName();
- var version = platformConfig.version();
+ const name = unorm.nfd(platformConfig.name());
+ const pkg = platformConfig.ios_CFBundleIdentifier() || platformConfig.packageName();
+ const version = platformConfig.version();
- var originalName = path.basename(locations.xcodeCordovaProj);
+ const originalName = path.basename(locations.xcodeCordovaProj);
// Update package id (bundle id)
- var plistFile = path.join(locations.xcodeCordovaProj, originalName + '-Info.plist');
- var infoPlist = plist.parse(fs.readFileSync(plistFile, 'utf8'));
+ const plistFile = path.join(locations.xcodeCordovaProj, originalName + '-Info.plist');
+ const infoPlist = plist.parse(fs.readFileSync(plistFile, 'utf8'));
infoPlist.CFBundleIdentifier = pkg;
// Update version (bundle version)
infoPlist.CFBundleShortVersionString = version;
- var CFBundleVersion = platformConfig.ios_CFBundleVersion() || default_CFBundleVersion(version);
+ const CFBundleVersion = platformConfig.ios_CFBundleVersion() || default_CFBundleVersion(version);
infoPlist.CFBundleVersion = CFBundleVersion;
// Update Author if present
- var author = platformConfig.author();
- var copyRight = infoPlist.NSHumanReadableCopyright;
+ const author = platformConfig.author();
+ const copyRight = infoPlist.NSHumanReadableCopyright;
if (copyRight && author) {
infoPlist.NSHumanReadableCopyright = copyRight.replace('--AUTHOR--', author);
}
// replace Info.plist ATS entries according to <access> and <allow-navigation> config.xml entries
- var ats = writeATSEntries(platformConfig);
+ const ats = writeATSEntries(platformConfig);
if (Object.keys(ats).length > 0) {
infoPlist.NSAppTransportSecurity = ats;
} else {
delete infoPlist.NSAppTransportSecurity;
}
- var info_contents = plist.build(infoPlist);
+ let info_contents = plist.build(infoPlist);
info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g, '<string></string>');
fs.writeFileSync(plistFile, info_contents, 'utf-8');
events.emit('verbose', 'Wrote out OSX Bundle Identifier to "' + pkg + '"');
@@ -188,7 +188,7 @@ function updateProject (platformConfig, locations) {
locations.pbxproj = path.join(locations.xcodeProjDir, 'project.pbxproj');
// Hack this shi*t
- var pbx_contents = fs.readFileSync(locations.pbxproj, 'utf-8');
+ let pbx_contents = fs.readFileSync(locations.pbxproj, 'utf-8');
pbx_contents = pbx_contents.split(originalName).join(name);
fs.writeFileSync(locations.pbxproj, pbx_contents, 'utf-8');
events.emit('verbose', 'Wrote out OSX Product Name and updated XCode project file names from "' + originalName + '" to "' + name + '".');
@@ -204,12 +204,12 @@ function handleBuildSettings (platformConfig, locations) {
function handleIcons (projectConfig, platformRoot) {
// Update icons
- var icons = projectConfig.getIcons('osx');
- var appRoot = path.dirname(projectConfig.path);
+ const icons = projectConfig.getIcons('osx');
+ const appRoot = path.dirname(projectConfig.path);
// See https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/Designing.html
// for application images sizes reference.
- var platformIcons = [
+ const platformIcons = [
{ dest: 'icon-1024x1024.png', width: 1024, height: 1024 },
{ dest: 'icon-512x512.png', width: 512, height: 512 },
{ dest: 'icon-256x256.png', width: 256, height: 256 },
@@ -220,10 +220,10 @@ function handleIcons (projectConfig, platformRoot) {
];
platformIcons.forEach(function (item) {
- var icon = icons.getBySize(item.width, item.height) || icons.getDefault();
+ const icon = icons.getBySize(item.width, item.height) || icons.getDefault();
if (icon) {
- var src = path.join(appRoot, icon.src);
- var dst = path.join(platformRoot, 'Images.xcassets/AppIcon.appiconset/', item.dest);
+ const src = path.join(appRoot, icon.src);
+ const dst = path.join(platformRoot, 'Images.xcassets/AppIcon.appiconset/', item.dest);
events.emit('verbose', 'Copying icon from ' + src + ' to ' + dst);
shell.cp('-f', src, dst);
}
@@ -242,8 +242,8 @@ function handleIcons (projectConfig, platformRoot) {
}
*/
function processAccessAndAllowNavigationEntries (config) {
- var accesses = config.getAccesses();
- var allow_navigations = config.getAllowNavigations();
+ const accesses = config.getAccesses();
+ const allow_navigations = config.getAllowNavigations();
// we concat allow_navigations and accesses, after processing accesses
return allow_navigations.concat(accesses.map(function (obj) {
@@ -253,14 +253,14 @@ function processAccessAndAllowNavigationEntries (config) {
return obj;
// we reduce the array to an object with all the entries processed (key is Hostname)
})).reduce(function (previousReturn, currentElement) {
- var obj = parseWhitelistUrlForATS(currentElement.href, currentElement.minimum_tls_version, currentElement.requires_forward_secrecy);
+ const obj = parseWhitelistUrlForATS(currentElement.href, currentElement.minimum_tls_version, currentElement.requires_forward_secrecy);
if (obj) {
// we 'union' duplicate entries
- var item = previousReturn[obj.Hostname];
+ let item = previousReturn[obj.Hostname];
if (!item) {
item = {};
}
- for (var o in obj) {
+ for (const o in obj) {
if (Object.prototype.hasOwnProperty.call(obj, o)) {
item[o] = obj[o];
}
@@ -286,7 +286,7 @@ function processAccessAndAllowNavigationEntries (config) {
function parseWhitelistUrlForATS (url, minimum_tls_version, requires_forward_secrecy) {
// @todo 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api
var href = URL.parse(url); // eslint-disable-line
- var retObj = {};
+ const retObj = {};
retObj.Hostname = href.hostname;
if (url === '*') {
@@ -299,9 +299,9 @@ function parseWhitelistUrlForATS (url, minimum_tls_version, requires_forward_sec
if (!retObj.Hostname) {
// check origin, if it allows subdomains (wildcard in hostname), we set NSIncludesSubdomains to YES. Default is NO
- var subdomain1 = '/*.'; // wildcard in hostname
- var subdomain2 = '*://*.'; // wildcard in hostname and protocol
- var subdomain3 = '*://'; // wildcard in protocol only
+ const subdomain1 = '/*.'; // wildcard in hostname
+ const subdomain2 = '*://*.'; // wildcard in hostname and protocol
+ const subdomain3 = '*://'; // wildcard in protocol only
if (href.pathname.indexOf(subdomain1) === 0) {
retObj.NSIncludesSubdomains = true;
retObj.Hostname = href.pathname.substring(subdomain1.length);
@@ -320,7 +320,7 @@ function parseWhitelistUrlForATS (url, minimum_tls_version, requires_forward_sec
retObj.NSExceptionMinimumTLSVersion = minimum_tls_version;
}
- var rfs = (requires_forward_secrecy === 'true');
+ const rfs = (requires_forward_secrecy === 'true');
if (requires_forward_secrecy && !rfs) { // default is true
retObj.NSExceptionRequiresForwardSecrecy = false;
}
@@ -340,21 +340,21 @@ function parseWhitelistUrlForATS (url, minimum_tls_version, requires_forward_sec
in config.xml
*/
function writeATSEntries (config) {
- var pObj = processAccessAndAllowNavigationEntries(config);
+ const pObj = processAccessAndAllowNavigationEntries(config);
- var ats = {};
+ const ats = {};
- for (var hostname in pObj) {
+ for (const hostname in pObj) {
if (Object.prototype.hasOwnProperty.call(pObj, hostname)) {
if (hostname === '*') {
ats.NSAllowsArbitraryLoads = true;
continue;
}
- var entry = pObj[hostname];
- var exceptionDomain = {};
+ const entry = pObj[hostname];
+ const exceptionDomain = {};
- for (var key in entry) {
+ for (const key in entry) {
if (Object.prototype.hasOwnProperty.call(entry, key) && key !== 'Hostname') {
exceptionDomain[key] = entry[key];
}
diff --git a/bin/templates/scripts/cordova/lib/projectFile.js b/bin/templates/scripts/cordova/lib/projectFile.js
index b373464..d75fc35 100644
--- a/bin/templates/scripts/cordova/lib/projectFile.js
+++ b/bin/templates/scripts/cordova/lib/projectFile.js
@@ -19,47 +19,47 @@
/* jshint node: true */
-var xcode = require('xcode');
-var plist = require('plist');
-var _ = require('underscore');
-var path = require('path');
-var fs = require('fs');
-var shell = require('shelljs');
+const xcode = require('xcode');
+const plist = require('plist');
+const _ = require('underscore');
+const path = require('path');
+const fs = require('fs');
+const shell = require('shelljs');
-var pluginHandlers = require('./plugman/pluginHandlers');
-var CordovaError = require('cordova-common').CordovaError;
+const pluginHandlers = require('./plugman/pluginHandlers');
+const CordovaError = require('cordova-common').CordovaError;
-var cachedProjectFiles = {};
+const cachedProjectFiles = {};
function parseProjectFile (locations) {
- var project_dir = locations.root;
- var pbxPath = locations.pbxproj;
+ const project_dir = locations.root;
+ const pbxPath = locations.pbxproj;
if (cachedProjectFiles[project_dir]) {
return cachedProjectFiles[project_dir];
}
- var xcodeproj = xcode.project(pbxPath);
+ const xcodeproj = xcode.project(pbxPath);
xcodeproj.parseSync();
- var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
- var plist_file_entry = _.find(xcBuildConfiguration, function (entry) { return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE; });
- var plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'));
- var config_file = path.join(path.dirname(plist_file), 'config.xml');
+ const xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
+ const plist_file_entry = _.find(xcBuildConfiguration, function (entry) { return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE; });
+ const plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'));
+ const config_file = path.join(path.dirname(plist_file), 'config.xml');
if (!fs.existsSync(plist_file) || !fs.existsSync(config_file)) {
throw new CordovaError('could not find -Info.plist file, or config.xml file.');
}
- var frameworks_file = path.join(project_dir, 'frameworks.json');
- var frameworks = {};
+ const frameworks_file = path.join(project_dir, 'frameworks.json');
+ let frameworks = {};
try {
frameworks = require(frameworks_file);
} catch (e) { }
- var xcode_dir = path.dirname(plist_file);
- var pluginsDir = path.resolve(xcode_dir, 'Plugins');
- var resourcesDir = path.resolve(xcode_dir, 'Resources');
+ const xcode_dir = path.dirname(plist_file);
+ const pluginsDir = path.resolve(xcode_dir, 'Plugins');
+ const resourcesDir = path.resolve(xcode_dir, 'Resources');
cachedProjectFiles[project_dir] = {
plugins_dir: pluginsDir,
@@ -107,13 +107,13 @@ xcode.project.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) {
};
xcode.project.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) {
- var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
+ const sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
if (sources) {
sources.files.push(pbxBuildPhaseObj(file));
}
};
xcode.project.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) {
- var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
+ const sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
if (sources) {
sources.files = _.reject(sources.files, function (file) {
return file.comment === longComment(file);
@@ -123,9 +123,9 @@ xcode.project.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file)
// special handlers to add frameworks to the 'Embed Frameworks' build phase, needed for custom frameworks
// see CB-9517. should probably be moved to node-xcode.
-var util = require('util');
+const util = require('util');
function pbxBuildPhaseObj (file) {
- var obj = Object.create(null);
+ const obj = Object.create(null);
obj.value = file.uuid;
obj.comment = longComment(file);
return obj;
diff --git a/bin/templates/scripts/cordova/lib/run.js b/bin/templates/scripts/cordova/lib/run.js
index db9a6bb..ff00eb3 100644
--- a/bin/templates/scripts/cordova/lib/run.js
+++ b/bin/templates/scripts/cordova/lib/run.js
@@ -19,12 +19,12 @@
/* jshint node: true */
-var path = require('path');
-var build = require('./build');
-var spawn = require('./spawn');
-var events = require('cordova-common').events;
+const path = require('path');
+const build = require('./build');
+const spawn = require('./spawn');
+const events = require('cordova-common').events;
-var projectPath = path.join(__dirname, '..', '..');
+const projectPath = path.join(__dirname, '..', '..');
module.exports.run = function (runOptions) {
return Promise.resolve().then(function () {
@@ -34,7 +34,7 @@ module.exports.run = function (runOptions) {
}).then(function () {
return build.findXCodeProjectIn(projectPath);
}).then(function (projectName) {
- var appPath = path.join(projectPath, 'build', projectName + '.app');
+ const appPath = path.join(projectPath, 'build', projectName + '.app');
return runApp(appPath, projectName);
});
};
@@ -44,7 +44,7 @@ module.exports.run = function (runOptions) {
* @return {Promise} Resolves when run succeeds otherwise rejects
*/
function runApp (appDir, appName) {
- var binPath = path.join(appDir, 'Contents', 'MacOS', appName);
+ const binPath = path.join(appDir, 'Contents', 'MacOS', appName);
events.emit('log', 'Starting: ' + binPath);
return spawn(binPath);
}
diff --git a/bin/templates/scripts/cordova/lib/spawn.js b/bin/templates/scripts/cordova/lib/spawn.js
index 030188f..e93cf31 100644
--- a/bin/templates/scripts/cordova/lib/spawn.js
+++ b/bin/templates/scripts/cordova/lib/spawn.js
@@ -17,7 +17,7 @@
under the License.
*/
-var proc = require('child_process');
+const proc = require('child_process');
/**
* Run specified command with arguments
@@ -30,7 +30,7 @@ var proc = require('child_process');
module.exports = function (cmd, args, opt_cwd) {
return new Promise((resolve, reject) => {
try {
- var child = proc.spawn(cmd, args, { cwd: opt_cwd, stdio: 'inherit' });
+ const child = proc.spawn(cmd, args, { cwd: opt_cwd, stdio: 'inherit' });
child.on('exit', function (code) {
if (code) {
diff --git a/bin/templates/scripts/cordova/run b/bin/templates/scripts/cordova/run
index 6e2ca23..f37dce2 100755
--- a/bin/templates/scripts/cordova/run
+++ b/bin/templates/scripts/cordova/run
@@ -19,9 +19,9 @@
under the License.
*/
-var args = process.argv;
-var Api = require('./Api');
-var nopt = require('nopt');
+const args = process.argv;
+const Api = require('./Api');
+const nopt = require('nopt');
// Handle help flag
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
@@ -30,7 +30,7 @@ if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >=
}
// Parse arguments (includes build params as well)
-var opts = nopt({
+const opts = nopt({
verbose: Boolean,
silent: Boolean,
debug: Boolean,
@@ -54,7 +54,7 @@ opts.argv = opts.argv.remain;
new Api().run(opts).then(function () {
console.log('** RUN SUCCEEDED **');
}, function (err) {
- var errorMessage = (err && err.stack) ? err.stack : err;
+ const errorMessage = (err && err.stack) ? err.stack : err;
console.error(errorMessage);
process.exit(2);
});
diff --git a/bin/templates/scripts/cordova/version b/bin/templates/scripts/cordova/version
index e608e14..f7f99ad 100755
--- a/bin/templates/scripts/cordova/version
+++ b/bin/templates/scripts/cordova/version
@@ -26,7 +26,7 @@
*/
// Coho updates this line
-var VERSION = '6.1.0-dev';
+const VERSION = '6.1.0-dev';
module.exports.version = VERSION;
diff --git a/bin/update b/bin/update
index 8f2bb6e..78603db 100755
--- a/bin/update
+++ b/bin/update
@@ -19,9 +19,9 @@
under the License.
*/
-var path = require('path');
-var Api = require('./templates/scripts/cordova/Api');
-var args = require('nopt')({
+const path = require('path');
+const Api = require('./templates/scripts/cordova/Api');
+const args = require('nopt')({
link: Boolean,
shared: Boolean, // alias for --link
help: Boolean
diff --git a/bin/update_cordova_subproject b/bin/update_cordova_subproject
index 6b3b60d..4e75784 100755
--- a/bin/update_cordova_subproject
+++ b/bin/update_cordova_subproject
@@ -19,8 +19,8 @@
under the License.
*/
-var create = require('./lib/create');
-var args;
+const create = require('./lib/create');
+let args;
if (process.argv.length < 3) {
create.updateSubprojectHelp();
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index 9b287a2..494d213 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -24,20 +24,20 @@
* @private
*/
-var cordova = require('cordova');
-var utils = require('cordova/utils');
-var base64 = require('cordova/base64');
+const cordova = require('cordova');
+const utils = require('cordova/utils');
+const base64 = require('cordova/base64');
function massageMessageNativeToJs (message) {
if (message.CDVType === 'ArrayBuffer') {
- var stringToArrayBuffer = function (str) {
- var ret = new Uint8Array(str.length);
- for (var i = 0; i < str.length; i++) {
+ const stringToArrayBuffer = function (str) {
+ const ret = new Uint8Array(str.length);
+ for (let i = 0; i < str.length; i++) {
ret[i] = str.charCodeAt(i);
}
return ret.buffer;
};
- var base64ToArrayBuffer = function (b64) {
+ const base64ToArrayBuffer = function (b64) {
return stringToArrayBuffer(atob(b64));
};
message = base64ToArrayBuffer(message.data);
@@ -46,7 +46,7 @@ function massageMessageNativeToJs (message) {
}
function convertMessageToArgsNativeToJs (message) {
- var args = [];
+ const args = [];
if (!message || !Object.prototype.hasOwnProperty.call(message, 'CDVType')) {
args.push(message);
} else if (message.CDVType === 'MultiPart') {
@@ -63,7 +63,7 @@ function massageArgsJsToNative (args) {
if (!args || utils.typeName(args) !== 'Array') {
return args;
}
- var ret = [];
+ const ret = [];
args.forEach(function (arg, i) {
if (utils.typeName(arg) === 'ArrayBuffer') {
ret.push({
@@ -78,8 +78,8 @@ function massageArgsJsToNative (args) {
}
function OSXExec () {
- var successCallback, failCallback, service, action, actionArgs;
- var callbackId = 'INVALID';
+ let successCallback, failCallback, service, action, actionArgs;
+ let callbackId = 'INVALID';
successCallback = arguments[0];
failCallback = arguments[1];
@@ -105,8 +105,8 @@ function OSXExec () {
}
OSXExec.nativeCallback = function (callbackId, status, message, keepCallback) {
- var success = status === 0 || status === 1;
- var args = convertMessageToArgsNativeToJs(message);
+ const success = status === 0 || status === 1;
+ const args = convertMessageToArgsNativeToJs(message);
cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org