You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2018/06/02 06:28:42 UTC

[cordova-common] 01/03: Revert "Use .includes and .startsWith instead of .indexOf"

This is an automated email from the ASF dual-hosted git repository.

dpogue pushed a commit to branch 2.2.x
in repository https://gitbox.apache.org/repos/asf/cordova-common.git

commit 6d4193c27bc00507f618bc45a76a53a24a72a429
Author: Darryl Pogue <da...@dpogue.ca>
AuthorDate: Fri Jun 1 23:18:27 2018 -0700

    Revert "Use .includes and .startsWith instead of .indexOf"
    
    This reverts commit 3e9a4efdcc8670c015cf6fd5419ef9bbb9f9cf40.
    This restores compatibility with nodeJS 4.x.
---
 spec/fixtures/projects/windows/www/cordova-2.6.0.js | 4 ++--
 src/ConfigChanges/ConfigFile.js                     | 6 +++---
 src/ConfigParser/ConfigParser.js                    | 2 +-
 src/CordovaLogger.js                                | 6 +++---
 src/PlatformJson.js                                 | 4 ++--
 src/superspawn.js                                   | 2 +-
 src/util/xml-helpers.js                             | 6 +++---
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/spec/fixtures/projects/windows/www/cordova-2.6.0.js b/spec/fixtures/projects/windows/www/cordova-2.6.0.js
index f8c32b2..bb99ae6 100644
--- a/spec/fixtures/projects/windows/www/cordova-2.6.0.js
+++ b/spec/fixtures/projects/windows/www/cordova-2.6.0.js
@@ -2611,7 +2611,7 @@ function getBasicAuthHeader(urlString) {
         var origin = protocol + url.host;
 
         // check whether there are the username:password credentials in the url
-        if (!url.href.startsWith(origin)) { // credentials found
+        if (url.href.indexOf(origin) != 0) { // credentials found
             var atIndex = url.href.indexOf("@");
             credentials = url.href.substring(protocol.length, atIndex);
         }
@@ -6266,7 +6266,7 @@ module.exports = {
 
         var name = "unknown";
         hostNames.some(function (nm) {
-            if (nm.displayName.includes(".local")) {
+            if (nm.displayName.indexOf(".local") > -1) {
                 name = nm.displayName.split(".local")[0];
                 return true;
             }
diff --git a/src/ConfigChanges/ConfigFile.js b/src/ConfigChanges/ConfigFile.js
index 54353ef..2e5ed5f 100644
--- a/src/ConfigChanges/ConfigFile.js
+++ b/src/ConfigChanges/ConfigFile.js
@@ -168,16 +168,16 @@ function resolveConfigFilePath (project_dir, platform, file) {
 
     file = path.normalize(file);
 
-    if (file.includes('*')) {
+    if (file.indexOf('*') > -1) {
         // handle wildcards in targets using glob.
         matches = modules.glob.sync(path.join(project_dir, '**', file));
         if (matches.length) filepath = matches[0];
 
         // [CB-5989] multiple Info.plist files may exist. default to $PROJECT_NAME-Info.plist
-        if (matches.length > 1 && file.includes('-Info.plist')) {
+        if (matches.length > 1 && file.indexOf('-Info.plist') > -1) {
             var plistName = getIOSProjectname(project_dir) + '-Info.plist';
             for (var i = 0; i < matches.length; i++) {
-                if (matches[i].includes(plistName)) {
+                if (matches[i].indexOf(plistName) > -1) {
                     filepath = matches[i];
                     break;
                 }
diff --git a/src/ConfigParser/ConfigParser.js b/src/ConfigParser/ConfigParser.js
index a393755..1a98c3a 100644
--- a/src/ConfigParser/ConfigParser.js
+++ b/src/ConfigParser/ConfigParser.js
@@ -57,7 +57,7 @@ function getCordovaNamespacePrefix (doc) {
     var rootAtribs = Object.getOwnPropertyNames(doc.getroot().attrib);
     var prefix = 'cdv';
     for (var j = 0; j < rootAtribs.length; j++) {
-        if (rootAtribs[j].startsWith('xmlns:') &&
+        if (rootAtribs[j].indexOf('xmlns:') === 0 &&
             doc.getroot().attrib[rootAtribs[j]] === 'http://cordova.apache.org/ns/1.0') {
             var strings = rootAtribs[j].split(':');
             prefix = strings[1];
diff --git a/src/CordovaLogger.js b/src/CordovaLogger.js
index b5c3564..4d77608 100644
--- a/src/CordovaLogger.js
+++ b/src/CordovaLogger.js
@@ -161,9 +161,9 @@ CordovaLogger.prototype.setLevel = function (logLevel) {
  * @return  {CordovaLogger}     Current instance, to allow calls chaining.
  */
 CordovaLogger.prototype.adjustLevel = function (opts) {
-    if (opts.verbose || (Array.isArray(opts) && opts.includes('--verbose'))) {
+    if (opts.verbose || (Array.isArray(opts) && opts.indexOf('--verbose') !== -1)) {
         this.setLevel('verbose');
-    } else if (opts.silent || (Array.isArray(opts) && opts.includes('--silent'))) {
+    } else if (opts.silent || (Array.isArray(opts) && opts.indexOf('--silent') !== -1)) {
         this.setLevel('error');
     }
 
@@ -209,7 +209,7 @@ function formatError (error, isVerbose) {
         message = error;
     }
 
-    if (typeof message === 'string' && !message.toUpperCase().startsWith('ERROR:')) {
+    if (typeof message === 'string' && message.toUpperCase().indexOf('ERROR:') !== 0) {
         // Needed for backward compatibility with external tools
         message = 'Error: ' + message;
     }
diff --git a/src/PlatformJson.js b/src/PlatformJson.js
index 86dace3..7eaf1a2 100644
--- a/src/PlatformJson.js
+++ b/src/PlatformJson.js
@@ -111,7 +111,7 @@ PlatformJson.prototype.addPluginMetadata = function (pluginInfo) {
         })
         .filter(function (metadata) {
             // Filter out modules which are already added to metadata
-            return !installedPaths.includes(metadata.file);
+            return installedPaths.indexOf(metadata.file) === -1;
         });
 
     this.root.modules = installedModules.concat(modulesToInstall);
@@ -151,7 +151,7 @@ PlatformJson.prototype.removePluginMetadata = function (pluginInfo) {
     this.root.modules = installedModules
         .filter(function (installedModule) {
             // Leave only those metadatas which 'file' is not in removed modules
-            return !modulesToRemove.includes(installedModule.file);
+            return (modulesToRemove.indexOf(installedModule.file) === -1);
         });
 
     if (this.root.plugin_metadata) {
diff --git a/src/superspawn.js b/src/superspawn.js
index 99e3057..8051184 100644
--- a/src/superspawn.js
+++ b/src/superspawn.js
@@ -30,7 +30,7 @@ var iswin32 = process.platform === 'win32';
 function resolveWindowsExe (cmd) {
     var winExtensions = ['.exe', '.bat', '.cmd', '.js', '.vbs'];
     function isValidExe (c) {
-        return winExtensions.includes(path.extname(c)) && fs.existsSync(c);
+        return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c);
     }
     if (isValidExe(cmd)) {
         return cmd;
diff --git a/src/util/xml-helpers.js b/src/util/xml-helpers.js
index ca65bfa..31922be 100644
--- a/src/util/xml-helpers.js
+++ b/src/util/xml-helpers.js
@@ -254,7 +254,7 @@ var BLACKLIST = ['platform', 'feature', 'plugin', 'engine'];
 var SINGLETONS = ['content', 'author', 'name'];
 function mergeXml (src, dest, platform, clobber) {
     // Do nothing for blacklisted tags.
-    if (BLACKLIST.includes(src.tag)) return;
+    if (BLACKLIST.indexOf(src.tag) !== -1) return;
 
     // Handle attributes
     Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) {
@@ -286,9 +286,9 @@ function mergeXml (src, dest, platform, clobber) {
         var query = srcTag + '';
         var shouldMerge = true;
 
-        if (BLACKLIST.includes(srcTag)) return;
+        if (BLACKLIST.indexOf(srcTag) !== -1) return;
 
-        if (SINGLETONS.includes(srcTag)) {
+        if (SINGLETONS.indexOf(srcTag) !== -1) {
             foundChild = dest.find(query);
             if (foundChild) {
                 destChild = foundChild;

-- 
To stop receiving notification emails like this one, please contact
dpogue@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org