You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by au...@apache.org on 2017/07/18 16:56:52 UTC
[1/4] cordova-common git commit: CB-12895 : set up eslint and removed
jshint
Repository: cordova-common
Updated Branches:
refs/heads/master 1cdc1248a -> 54450166d
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/superspawn.js
----------------------------------------------------------------------
diff --git a/src/superspawn.js b/src/superspawn.js
index 96ec09d..424934e 100644
--- a/src/superspawn.js
+++ b/src/superspawn.js
@@ -24,12 +24,12 @@ var _ = require('underscore');
var Q = require('q');
var shell = require('shelljs');
var events = require('./events');
-var iswin32 = process.platform == 'win32';
+var iswin32 = process.platform === 'win32';
// On Windows, spawn() for batch files requires absolute path & having the extension.
-function resolveWindowsExe(cmd) {
+function resolveWindowsExe (cmd) {
var winExtensions = ['.exe', '.bat', '.cmd', '.js', '.vbs'];
- function isValidExe(c) {
+ function isValidExe (c) {
return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c);
}
if (isValidExe(cmd)) {
@@ -37,7 +37,7 @@ function resolveWindowsExe(cmd) {
}
cmd = shell.which(cmd) || cmd;
if (!isValidExe(cmd)) {
- winExtensions.some(function(ext) {
+ winExtensions.some(function (ext) {
if (fs.existsSync(cmd + ext)) {
cmd = cmd + ext;
return true;
@@ -47,7 +47,7 @@ function resolveWindowsExe(cmd) {
return cmd;
}
-function maybeQuote(a) {
+function maybeQuote (a) {
if (/^[^"].*[ &].*[^"]/.test(a)) return '"' + a + '"';
return a;
}
@@ -85,7 +85,7 @@ function maybeQuote(a) {
* 'stderr': ...
* }
*/
-exports.spawn = function(cmd, args, opts) {
+exports.spawn = function (cmd, args, opts) {
args = args || [];
opts = opts || {};
var spawnOpts = {};
@@ -95,7 +95,7 @@ exports.spawn = function(cmd, args, opts) {
cmd = resolveWindowsExe(cmd);
// If we couldn't find the file, likely we'll end up failing,
// but for things like "del", cmd will do the trick.
- if (path.extname(cmd) != '.exe') {
+ if (path.extname(cmd) !== '.exe') {
var cmdArgs = '"' + [cmd].concat(args).map(maybeQuote).join(' ') + '"';
// We need to use /s to ensure that spaces are parsed properly with cmd spawned content
args = [['/s', '/c', cmdArgs].join(' ')];
@@ -137,7 +137,7 @@ exports.spawn = function(cmd, args, opts) {
if (child.stdout) {
child.stdout.setEncoding('utf8');
- child.stdout.on('data', function(data) {
+ child.stdout.on('data', function (data) {
capturedOut += data;
d.notify({'stdout': data});
});
@@ -145,7 +145,7 @@ exports.spawn = function(cmd, args, opts) {
if (child.stderr) {
child.stderr.setEncoding('utf8');
- child.stderr.on('data', function(data) {
+ child.stderr.on('data', function (data) {
capturedErr += data;
d.notify({'stderr': data});
});
@@ -153,10 +153,10 @@ exports.spawn = function(cmd, args, opts) {
child.on('close', whenDone);
child.on('error', whenDone);
- function whenDone(arg) {
+ function whenDone (arg) {
child.removeListener('close', whenDone);
child.removeListener('error', whenDone);
- var code = typeof arg == 'number' ? arg : arg && arg.code;
+ var code = typeof arg === 'number' ? arg : arg && arg.code;
events.emit('verbose', 'Command finished with error code ' + code + ': ' + cmd + ' ' + args);
if (code === 0) {
@@ -181,10 +181,9 @@ exports.spawn = function(cmd, args, opts) {
return d.promise;
};
-exports.maybeSpawn = function(cmd, args, opts) {
+exports.maybeSpawn = function (cmd, args, opts) {
if (fs.existsSync(cmd)) {
return exports.spawn(cmd, args, opts);
}
return Q(null);
};
-
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/util/addProperty.js
----------------------------------------------------------------------
diff --git a/src/util/addProperty.js b/src/util/addProperty.js
index 7dc4dc1..3e48174 100644
--- a/src/util/addProperty.js
+++ b/src/util/addProperty.js
@@ -17,8 +17,8 @@
under the License.
*/
-module.exports = function addProperty(module, property, modulePath, obj) {
-
+module.exports = function addProperty (module, property, modulePath, obj) {
+
obj = obj || module.exports;
// Add properties as getter to delay load the modules on first invocation
Object.defineProperty(obj, property, {
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/src/util/plist-helpers.js b/src/util/plist-helpers.js
index 1222fa8..5ec4c1d 100644
--- a/src/util/plist-helpers.js
+++ b/src/util/plist-helpers.js
@@ -15,32 +15,32 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-*/
+*/
+/* eslint no-useless-escape: 0 */
// contains PLIST utility functions
-var __ = require('underscore');
+var __ = require('underscore');
var plist = require('plist');
// adds node to doc at selector
module.exports.graftPLIST = graftPLIST;
-function graftPLIST(doc, xml, selector) {
- var obj = plist.parse('<plist>'+xml+'</plist>');
+function graftPLIST (doc, xml, selector) {
+ var obj = plist.parse('<plist>' + xml + '</plist>');
var node = doc[selector];
- if (node && Array.isArray(node) && Array.isArray(obj)){
+ if (node && Array.isArray(node) && Array.isArray(obj)) {
node = node.concat(obj);
- for (var i =0;i<node.length; i++){
- for (var j=i+1; j<node.length; ++j) {
- if (nodeEqual(node[i], node[j]))
- node.splice(j--,1);
+ for (var i = 0; i < node.length; i++) {
+ for (var j = i + 1; j < node.length; ++j) {
+ if (nodeEqual(node[i], node[j])) { node.splice(j--, 1); }
}
}
doc[selector] = node;
} else {
- //plist uses objects for <dict>. If we have two dicts we merge them instead of
+ // plist uses objects for <dict>. If we have two dicts we merge them instead of
// overriding the old one. See CB-6472
- if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)){//arrays checked above
- __.extend(obj,node);
+ if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)) { // arrays checked above
+ __.extend(obj, node);
}
doc[selector] = obj;
}
@@ -50,15 +50,15 @@ function graftPLIST(doc, xml, selector) {
// removes node from doc at selector
module.exports.prunePLIST = prunePLIST;
-function prunePLIST(doc, xml, selector) {
- var obj = plist.parse('<plist>'+xml+'</plist>');
+function prunePLIST (doc, xml, selector) {
+ var obj = plist.parse('<plist>' + xml + '</plist>');
pruneOBJECT(doc, selector, obj);
return true;
}
-function pruneOBJECT(doc, selector, fragment) {
+function pruneOBJECT (doc, selector, fragment) {
if (Array.isArray(fragment) && Array.isArray(doc[selector])) {
var empty = true;
for (var i in fragment) {
@@ -66,13 +66,11 @@ function pruneOBJECT(doc, selector, fragment) {
empty = pruneOBJECT(doc[selector], j, fragment[i]) && empty;
}
}
- if (empty)
- {
+ if (empty) {
delete doc[selector];
return true;
}
- }
- else if (nodeEqual(doc[selector], fragment)) {
+ } else if (nodeEqual(doc[selector], fragment)) {
delete doc[selector];
return true;
}
@@ -80,14 +78,11 @@ function pruneOBJECT(doc, selector, fragment) {
return false;
}
-function nodeEqual(node1, node2) {
- if (typeof node1 != typeof node2)
- return false;
- else if (typeof node1 == 'string') {
- node2 = escapeRE(node2).replace(/\\\$\S+/gm,'(.*?)');
+function nodeEqual (node1, node2) {
+ if (typeof node1 !== typeof node2) { return false; } else if (typeof node1 === 'string') {
+ node2 = escapeRE(node2).replace(/\\\$\S+/gm, '(.*?)');
return new RegExp('^' + node2 + '$').test(node1);
- }
- else {
+ } else {
for (var key in node2) {
if (!nodeEqual(node1[key], node2[key])) return false;
}
@@ -96,6 +91,6 @@ function nodeEqual(node1, node2) {
}
// escape string for use in regex
-function escapeRE(str) {
+function escapeRE (str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --git a/src/util/xml-helpers.js b/src/util/xml-helpers.js
index cc2eb0f..e2c8fd3 100644
--- a/src/util/xml-helpers.js
+++ b/src/util/xml-helpers.js
@@ -15,32 +15,31 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-*/
-
-/* jshint sub:true, laxcomma:true */
+*/
/**
* contains XML utility functions, some of which are specific to elementtree
*/
-var fs = require('fs')
- , path = require('path')
- , _ = require('underscore')
- , et = require('elementtree')
- ;
+var fs = require('fs');
+var path = require('path');
+var _ = require('underscore');
+var et = require('elementtree');
- var ROOT = /^\/([^\/]*)/,
- ABSOLUTE = /^\/([^\/]*)\/(.*)/;
+/* eslint-disable no-useless-escape */
+var ROOT = /^\/([^\/]*)/;
+var ABSOLUTE = /^\/([^\/]*)\/(.*)/;
+/* eslint-enable no-useless-escape */
module.exports = {
// compare two et.XML nodes, see if they match
// compares tagName, text, attributes and children (recursively)
- equalNodes: function(one, two) {
- if (one.tag != two.tag) {
+ equalNodes: function (one, two) {
+ if (one.tag !== two.tag) {
return false;
- } else if (one.text.trim() != two.text.trim()) {
+ } else if (one.text.trim() !== two.text.trim()) {
return false;
- } else if (one._children.length != two._children.length) {
+ } else if (one._children.length !== two._children.length) {
return false;
}
@@ -56,13 +55,13 @@ module.exports = {
},
// adds node to doc at selector, creating parent if it doesn't exist
- graftXML: function(doc, nodes, selector, after) {
+ graftXML: function (doc, nodes, selector, after) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) {
- //Try to create the parent recursively if necessary
+ // Try to create the parent recursively if necessary
try {
- var parentToCreate = et.XML('<' + path.basename(selector) + '>'),
- parentSelector = path.dirname(selector);
+ var parentToCreate = et.XML('<' + path.basename(selector) + '>');
+ var parentSelector = path.dirname(selector);
this.graftXML(doc, [parentToCreate], parentSelector);
} catch (e) {
@@ -78,7 +77,7 @@ module.exports = {
var children = parent.getchildren();
var insertIdx = after ? findInsertIdx(children, after) : children.length;
- //TODO: replace with parent.insert after the bug in ElementTree is fixed
+ // TODO: replace with parent.insert after the bug in ElementTree is fixed
parent.getchildren().splice(insertIdx, 0, node);
}
});
@@ -88,7 +87,7 @@ module.exports = {
// adds new attributes to doc at selector
// Will only merge if attribute has not been modified already or --force is used
- graftXMLMerge: function(doc, nodes, selector, xml) {
+ graftXMLMerge: function (doc, nodes, selector, xml) {
var target = module.exports.resolveParent(doc, selector);
if (!target) return false;
@@ -107,7 +106,7 @@ module.exports = {
// overwrite all attributes to doc at selector with new attributes
// Will only overwrite if attribute has not been modified already or --force is used
- graftXMLOverwrite: function(doc, nodes, selector, xml) {
+ graftXMLOverwrite: function (doc, nodes, selector, xml) {
var target = module.exports.resolveParent(doc, selector);
if (!target) return false;
@@ -132,7 +131,7 @@ module.exports = {
},
// removes node from doc at selector
- pruneXML: function(doc, nodes, selector) {
+ pruneXML: function (doc, nodes, selector) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) return false;
@@ -149,7 +148,7 @@ module.exports = {
},
// restores attributes from doc at selector
- pruneXMLRestore: function(doc, selector, xml) {
+ pruneXMLRestore: function (doc, selector, xml) {
var target = module.exports.resolveParent(doc, selector);
if (!target) return false;
@@ -160,7 +159,7 @@ module.exports = {
return true;
},
- pruneXMLRemove: function(doc, selector, nodes) {
+ pruneXMLRemove: function (doc, selector, nodes) {
var target = module.exports.resolveParent(doc, selector);
if (!target) return false;
@@ -177,11 +176,10 @@ module.exports = {
},
-
parseElementtreeSync: function (filename) {
var contents = fs.readFileSync(filename, 'utf-8');
- if(contents) {
- //Windows is the BOM. Skip the Byte Order Mark.
+ if (contents) {
+ // Windows is the BOM. Skip the Byte Order Mark.
contents = contents.substring(contents.indexOf('<'));
}
return new et.ElementTree(et.XML(contents));
@@ -194,7 +192,7 @@ module.exports = {
if (ROOT.test(selector)) {
tagName = selector.match(ROOT)[1];
// test for wildcard "any-tag" root selector
- if (tagName == '*' || tagName === doc._root.tag) {
+ if (tagName === '*' || tagName === doc._root.tag) {
parent = doc._root;
// could be an absolute path, but not selecting the root
@@ -212,11 +210,12 @@ module.exports = {
}
};
-function findChild(node, parent) {
- var matchingKids = parent.findall(node.tag)
- , i, j;
+function findChild (node, parent) {
+ var matchingKids = parent.findall(node.tag);
+ var i;
+ var j;
- for (i = 0, j = matchingKids.length ; i < j ; i++) {
+ for (i = 0, j = matchingKids.length; i < j; i++) {
if (module.exports.equalNodes(node, matchingKids[i])) {
return matchingKids[i];
}
@@ -224,13 +223,13 @@ function findChild(node, parent) {
return null;
}
-function uniqueChild(node, parent) {
- var matchingKids = parent.findall(node.tag)
- , i = 0;
+function uniqueChild (node, parent) {
+ var matchingKids = parent.findall(node.tag);
+ var i = 0;
if (matchingKids.length === 0) {
return true;
- } else {
+ } else {
for (i; i < matchingKids.length; i++) {
if (module.exports.equalNodes(node, matchingKids[i])) {
return false;
@@ -244,51 +243,51 @@ function uniqueChild(node, parent) {
// of tags after which the insertion should be made. E.g. If we need to
// insert an element C, and the rule is that the order of children has to be
// As, Bs, Cs. After will be equal to "C;B;A".
-function findInsertIdx(children, after) {
- var childrenTags = children.map(function(child) { return child.tag; });
+function findInsertIdx (children, after) {
+ var childrenTags = children.map(function (child) { return child.tag; });
var afters = after.split(';');
- var afterIndexes = afters.map(function(current) { return childrenTags.lastIndexOf(current); });
- var foundIndex = _.find(afterIndexes, function(index) { return index != -1; });
+ var afterIndexes = afters.map(function (current) { return childrenTags.lastIndexOf(current); });
+ var foundIndex = _.find(afterIndexes, function (index) { return index !== -1; });
- //add to the beginning if no matching nodes are found
- return typeof foundIndex === 'undefined' ? 0 : foundIndex+1;
+ // add to the beginning if no matching nodes are found
+ return typeof foundIndex === 'undefined' ? 0 : foundIndex + 1;
}
-var BLACKLIST = ['platform', 'feature','plugin','engine'];
+var BLACKLIST = ['platform', 'feature', 'plugin', 'engine'];
var SINGLETONS = ['content', 'author', 'name'];
-function mergeXml(src, dest, platform, clobber) {
+function mergeXml (src, dest, platform, clobber) {
// Do nothing for blacklisted tags.
- if (BLACKLIST.indexOf(src.tag) != -1) return;
+ if (BLACKLIST.indexOf(src.tag) !== -1) return;
- //Handle attributes
+ // Handle attributes
Object.getOwnPropertyNames(src.attrib).forEach(function (attribute) {
if (clobber || !dest.attrib[attribute]) {
dest.attrib[attribute] = src.attrib[attribute];
}
});
- //Handle text
+ // Handle text
if (src.text && (clobber || !dest.text)) {
dest.text = src.text;
}
- //Handle children
+ // Handle children
src.getchildren().forEach(mergeChild);
- //Handle platform
+ // Handle platform
if (platform) {
src.findall('platform[@name="' + platform + '"]').forEach(function (platformElement) {
platformElement.getchildren().forEach(mergeChild);
});
}
- //Handle duplicate preference tags (by name attribute)
+ // Handle duplicate preference tags (by name attribute)
removeDuplicatePreferences(dest);
function mergeChild (srcChild) {
- var srcTag = srcChild.tag,
- destChild = new et.Element(srcTag),
- foundChild,
- query = srcTag + '',
- shouldMerge = true;
+ var srcTag = srcChild.tag;
+ var destChild = new et.Element(srcTag);
+ var foundChild;
+ var query = srcTag + '';
+ var shouldMerge = true;
if (BLACKLIST.indexOf(srcTag) !== -1) return;
@@ -299,11 +298,11 @@ function mergeXml(src, dest, platform, clobber) {
dest.remove(destChild);
}
} else {
- //Check for an exact match and if you find one don't add
+ // Check for an exact match and if you find one don't add
var mergeCandidates = dest.findall(query)
- .filter(function (foundChild) {
- return foundChild && textMatch(srcChild, foundChild) && attribMatch(srcChild, foundChild);
- });
+ .filter(function (foundChild) {
+ return foundChild && textMatch(srcChild, foundChild) && attribMatch(srcChild, foundChild);
+ });
if (mergeCandidates.length > 0) {
destChild = mergeCandidates[0];
@@ -316,20 +315,20 @@ function mergeXml(src, dest, platform, clobber) {
dest.append(destChild);
}
- function removeDuplicatePreferences(xml) {
+ function removeDuplicatePreferences (xml) {
// reduce preference tags to a hashtable to remove dupes
- var prefHash = xml.findall('preference[@name][@value]').reduce(function(previousValue, currentValue) {
+ var prefHash = xml.findall('preference[@name][@value]').reduce(function (previousValue, currentValue) {
previousValue[ currentValue.attrib.name ] = currentValue.attrib.value;
return previousValue;
}, {});
// remove all preferences
- xml.findall('preference[@name][@value]').forEach(function(pref) {
+ xml.findall('preference[@name][@value]').forEach(function (pref) {
xml.remove(pref);
});
// write new preferences
- Object.keys(prefHash).forEach(function(key, index) {
+ Object.keys(prefHash).forEach(function (key, index) {
var element = et.SubElement(xml, 'preference');
element.set('name', key);
element.set('value', this[key]);
@@ -340,24 +339,24 @@ function mergeXml(src, dest, platform, clobber) {
// Expose for testing.
module.exports.mergeXml = mergeXml;
-function textMatch(elm1, elm2) {
- var text1 = elm1.text ? elm1.text.replace(/\s+/, '') : '',
- text2 = elm2.text ? elm2.text.replace(/\s+/, '') : '';
+function textMatch (elm1, elm2) {
+ var text1 = elm1.text ? elm1.text.replace(/\s+/, '') : '';
+ var text2 = elm2.text ? elm2.text.replace(/\s+/, '') : '';
return (text1 === '' || text1 === text2);
}
-function attribMatch(one, two) {
+function attribMatch (one, two) {
var oneAttribKeys = Object.keys(one.attrib);
var twoAttribKeys = Object.keys(two.attrib);
- if (oneAttribKeys.length != twoAttribKeys.length) {
+ if (oneAttribKeys.length !== twoAttribKeys.length) {
return false;
}
for (var i = 0; i < oneAttribKeys.length; i++) {
var attribName = oneAttribKeys[i];
- if (one.attrib[attribName] != two.attrib[attribName]) {
+ if (one.attrib[attribName] !== two.attrib[attribName]) {
return false;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/4] cordova-common git commit: CB-12895 : set up eslint and removed
jshint
Posted by au...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/FileUpdater.spec.js
----------------------------------------------------------------------
diff --git a/spec/FileUpdater.spec.js b/spec/FileUpdater.spec.js
index 21659d3..0dccc01 100644
--- a/spec/FileUpdater.spec.js
+++ b/spec/FileUpdater.spec.js
@@ -36,20 +36,20 @@ FileUpdater.__set__('updatePathWithStats', function () {
});
// Create mock fs.Stats to simulate file or directory attributes.
-function mockFileStats(modified) {
+function mockFileStats (modified) {
return {
isFile: function () { return true; },
isDirectory: function () { return false; },
ctime: modified,
- mtime: modified,
+ mtime: modified
};
}
-function mockDirStats() {
+function mockDirStats () {
return {
isFile: function () { return false; },
isDirectory: function () { return true; },
ctime: null,
- mtime: null,
+ mtime: null
};
}
@@ -71,10 +71,10 @@ var mockFs = {
},
existsSync: function (fileOrDirPath) {
- return typeof(this.statMap[fileOrDirPath]) !== 'undefined';
+ return typeof (this.statMap[fileOrDirPath]) !== 'undefined';
},
- readdirSync: function(dirPath) {
+ readdirSync: function (dirPath) {
var result = this.dirMap[dirPath];
if (!result) throw new Error('Directory path not found: ' + dirPath);
return result;
@@ -94,9 +94,9 @@ var mockFs = {
this.cpPaths.push([sourcePath, targetPath]);
},
- rm: function(flags, path) {
+ rm: function (flags, path) {
this.rmPaths.push(path);
- },
+ }
};
FileUpdater.__set__('fs', mockFs);
FileUpdater.__set__('shell', mockFs);
@@ -113,14 +113,14 @@ var testTargetFile = 'testTargetFile';
var testTargetFile2 = 'testTargetFile2';
var testSubDir = 'testSubDir';
var now = new Date();
-var oneHourAgo = new Date(now.getTime() - 1*60*60*1000);
+var oneHourAgo = new Date(now.getTime() - 1 * 60 * 60 * 1000);
var testDirStats = mockDirStats();
var testFileStats = mockFileStats(now);
var testFileStats2 = mockFileStats(now);
var testFileStats3 = mockFileStats(now);
var nullLogger = function (message) {};
-describe('FileUpdater class', function() {
+describe('FileUpdater class', function () {
beforeEach(function () {
FileUpdater.updatePathWithStatsCalls = [];
@@ -157,34 +157,34 @@ describe('FileUpdater class', function() {
});
it('Test 004 : should copy when a file exists at source and target and times are the same',
- function () {
- var updated = FileUpdater.updatePathWithStats(
- testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(now),
- null, nullLogger);
- expect(updated).toBe(true);
- expect(mockFs.cpPaths.length).toBe(1);
- expect(mockFs.rmPaths.length).toBe(0);
- expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]);
- });
+ function () {
+ var updated = FileUpdater.updatePathWithStats(
+ testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(now),
+ null, nullLogger);
+ expect(updated).toBe(true);
+ expect(mockFs.cpPaths.length).toBe(1);
+ expect(mockFs.rmPaths.length).toBe(0);
+ expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]);
+ });
it('Test 005 : should copy when a file exists at source and target and target is older',
- function () {
- var updated = FileUpdater.updatePathWithStats(
- testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(oneHourAgo),
- null, nullLogger);
- expect(updated).toBe(true);
- expect(mockFs.cpPaths.length).toBe(1);
- expect(mockFs.rmPaths.length).toBe(0);
- expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]);
- });
+ function () {
+ var updated = FileUpdater.updatePathWithStats(
+ testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(oneHourAgo),
+ null, nullLogger);
+ expect(updated).toBe(true);
+ expect(mockFs.cpPaths.length).toBe(1);
+ expect(mockFs.rmPaths.length).toBe(0);
+ expect(mockFs.cpPaths[0]).toEqual([testSourceFile, testTargetFile]);
+ });
it('Test 006 : should do nothing when a file exists at source and target and target is newer',
- function () {
- var updated = FileUpdater.updatePathWithStats(
- testSourceFile, mockFileStats(oneHourAgo), testTargetFile, mockFileStats(now),
- null, nullLogger);
- expect(updated).toBe(false);
- expect(mockFs.cpPaths.length).toBe(0);
- expect(mockFs.rmPaths.length).toBe(0);
- });
+ function () {
+ var updated = FileUpdater.updatePathWithStats(
+ testSourceFile, mockFileStats(oneHourAgo), testTargetFile, mockFileStats(now),
+ null, nullLogger);
+ expect(updated).toBe(false);
+ expect(mockFs.cpPaths.length).toBe(0);
+ expect(mockFs.rmPaths.length).toBe(0);
+ });
it('Test 007 : should copy when a file exists at source and target and forcing update', function () {
var updated = FileUpdater.updatePathWithStats(
testSourceFile, mockFileStats(now), testTargetFile, mockFileStats(now),
@@ -455,11 +455,11 @@ describe('FileUpdater class', function() {
var mergedPathMap = FileUpdater.mergePathMaps(
[{
'': { subDir: testSourceDir, stats: testDirStats },
- testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats },
+ testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats }
}],
{
'': { subDir: testTargetDir, stats: testDirStats },
- testTargetFile: { subDir: testTargetDir, stats: testTargetFileStats },
+ testTargetFile: { subDir: testTargetDir, stats: testTargetFileStats }
},
testTargetDir);
expect(Object.keys(mergedPathMap).sort()).toEqual(['', testTargetFile]);
@@ -478,7 +478,7 @@ describe('FileUpdater class', function() {
var mergedPathMap = FileUpdater.mergePathMaps(
[{}],
{
- testTargetFile: { subDir: testTargetDir, stats: testTargetFileStats },
+ testTargetFile: { subDir: testTargetDir, stats: testTargetFileStats }
},
testTargetDir);
expect(Object.keys(mergedPathMap).sort()).toEqual([testTargetFile]);
@@ -491,7 +491,7 @@ describe('FileUpdater class', function() {
it('Tets 029 : should handle missing target files', function () {
var mergedPathMap = FileUpdater.mergePathMaps(
[{
- testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats },
+ testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats }
}],
{},
testTargetDir);
@@ -508,21 +508,21 @@ describe('FileUpdater class', function() {
[
{
'': { subDir: testSourceDir, stats: testDirStats },
- testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats },
+ testTargetFile: { subDir: testSourceDir, stats: testSourceFileStats }
},
{
'': { subDir: testSourceDir2, stats: testDirStats },
testTargetFile: { subDir: testSourceDir2, stats: testSourceFileStats2 },
- testTargetFile2: { subDir: testSourceDir2, stats: testSourceFileStats2 },
+ testTargetFile2: { subDir: testSourceDir2, stats: testSourceFileStats2 }
},
{
'': { subDir: testSourceDir3, stats: testDirStats },
- testTargetFile2: { subDir: testSourceDir3, stats: testSourceFileStats3 },
- },
+ testTargetFile2: { subDir: testSourceDir3, stats: testSourceFileStats3 }
+ }
],
{
'': { subDir: testTargetDir, stats: testDirStats },
- testTargetFile: { subDir: testTargetDir, stats: testTargetFileStats },
+ testTargetFile: { subDir: testTargetDir, stats: testTargetFileStats }
},
testTargetDir);
expect(Object.keys(mergedPathMap).sort()).toEqual(
@@ -560,7 +560,7 @@ describe('FileUpdater class', function() {
expect(FileUpdater.updatePathWithStatsCalls[0][2]).toBe(testTargetFile);
expect(FileUpdater.updatePathWithStatsCalls[0][3]).toEqual(testFileStats);
expect(FileUpdater.updatePathWithStatsCalls[0][4]).toEqual(
- {rootDir: testRootDir, all: true });
+ { rootDir: testRootDir, all: true });
});
it('Test 032 : should update a path without a separate root directory', function () {
mockFs.statMap[testTargetFile] = testFileStats;
@@ -598,20 +598,20 @@ describe('FileUpdater class', function() {
expect(FileUpdater.updatePathWithStatsCalls[0][4]).toBeUndefined();
});
it('Test 035 : should create the target\'s parent directory if it doesn\'t exist',
- function () {
- mockFs.statMap[path.join(testRootDir, testSourceFile)] = testFileStats2;
- var updated = FileUpdater.updatePath(
- testSourceFile, testTargetFile, { rootDir: testRootDir });
- expect(updated).toBe(true);
- expect(FileUpdater.updatePathWithStatsCalls.length).toBe(1);
- expect(FileUpdater.updatePathWithStatsCalls[0][0]).toBe(testSourceFile);
- expect(FileUpdater.updatePathWithStatsCalls[0][1]).toEqual(testFileStats2);
- expect(FileUpdater.updatePathWithStatsCalls[0][2]).toBe(testTargetFile);
- expect(FileUpdater.updatePathWithStatsCalls[0][3]).toBeNull();
- expect(FileUpdater.updatePathWithStatsCalls[0][4]).toEqual({rootDir: testRootDir });
- expect(mockFs.mkdirPaths.length).toBe(1);
- expect(mockFs.mkdirPaths[0]).toBe(testRootDir);
- });
+ function () {
+ mockFs.statMap[path.join(testRootDir, testSourceFile)] = testFileStats2;
+ var updated = FileUpdater.updatePath(
+ testSourceFile, testTargetFile, { rootDir: testRootDir });
+ expect(updated).toBe(true);
+ expect(FileUpdater.updatePathWithStatsCalls.length).toBe(1);
+ expect(FileUpdater.updatePathWithStatsCalls[0][0]).toBe(testSourceFile);
+ expect(FileUpdater.updatePathWithStatsCalls[0][1]).toEqual(testFileStats2);
+ expect(FileUpdater.updatePathWithStatsCalls[0][2]).toBe(testTargetFile);
+ expect(FileUpdater.updatePathWithStatsCalls[0][3]).toBeNull();
+ expect(FileUpdater.updatePathWithStatsCalls[0][4]).toEqual({ rootDir: testRootDir });
+ expect(mockFs.mkdirPaths.length).toBe(1);
+ expect(mockFs.mkdirPaths[0]).toBe(testRootDir);
+ });
});
describe('mergeAndUpdateDir method', function () {
@@ -642,8 +642,8 @@ describe('FileUpdater class', function() {
expect(updated).toBe(true);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(4);
- function validateUpdatePathWithStatsCall(
- index, subPath, sourceDir, sourceStats, targetDir, targetStats) {
+ function validateUpdatePathWithStatsCall (
+ index, subPath, sourceDir, sourceStats, targetDir, targetStats) {
var args = FileUpdater.updatePathWithStatsCalls[index];
expect(args[0]).toBe(path.join(sourceDir, subPath));
expect(args[1]).toEqual(sourceStats);
@@ -661,7 +661,7 @@ describe('FileUpdater class', function() {
testTargetDir,
testDirStats);
// Update the subdirectory.
- validateUpdatePathWithStatsCall(
+ validateUpdatePathWithStatsCall(
1,
testSubDir,
testSourceDir2,
@@ -717,8 +717,8 @@ describe('FileUpdater class', function() {
expect(updated).toBe(true);
expect(FileUpdater.updatePathWithStatsCalls.length).toBe(4);
- function validateUpdatePathWithStatsCall(
- index, subPath, sourceDir, sourceStats, targetDir, targetStats) {
+ function validateUpdatePathWithStatsCall (
+ index, subPath, sourceDir, sourceStats, targetDir, targetStats) {
var args = FileUpdater.updatePathWithStatsCalls[index];
expect(args[0]).toBe(path.join(sourceDir, subPath));
expect(args[1]).toEqual(sourceStats);
@@ -736,7 +736,7 @@ describe('FileUpdater class', function() {
testTargetDir,
testDirStats);
// Update the subdirectory.
- validateUpdatePathWithStatsCall(
+ validateUpdatePathWithStatsCall(
1,
testSubDir,
testSourceDir2,
@@ -758,7 +758,7 @@ describe('FileUpdater class', function() {
testSourceDir2,
testFileStats3,
testTargetDir,
- null);
+ null);
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/PlatformJson.spec.js
----------------------------------------------------------------------
diff --git a/spec/PlatformJson.spec.js b/spec/PlatformJson.spec.js
index f3ce22b..a92be65 100644
--- a/spec/PlatformJson.spec.js
+++ b/spec/PlatformJson.spec.js
@@ -29,7 +29,7 @@ var FAKE_MODULE = {
runs: true
};
-describe('PlatformJson class', function() {
+describe('PlatformJson class', function () {
it('Test 001 : should be constructable', function () {
expect(new PlatformJson()).toEqual(jasmine.any(PlatformJson));
});
@@ -37,7 +37,7 @@ describe('PlatformJson class', function() {
describe('instance', function () {
var platformJson;
var fakePlugin;
-
+
beforeEach(function () {
platformJson = new PlatformJson('/fake/path', 'android');
fakePlugin = jasmine.createSpyObj('fakePlugin', ['getJsModules']);
@@ -45,61 +45,61 @@ describe('PlatformJson class', function() {
fakePlugin.version = '1.0.0';
fakePlugin.getJsModules.and.returnValue([FAKE_MODULE]);
});
-
+
describe('addPluginMetadata method', function () {
it('Test 002 : should not throw if root "modules" property is missing', function () {
expect(function () {
platformJson.addPluginMetadata(fakePlugin);
}).not.toThrow();
});
-
+
it('Test 003 : should add each module to "root.modules" array', function () {
platformJson.addPluginMetadata(fakePlugin);
expect(platformJson.root.modules.length).toBe(1);
expect(platformJson.root.modules[0]).toEqual(jasmine.any(ModuleMetadata));
});
-
+
it('Test 004 : shouldn\'t add module if there is already module with the same file added', function () {
platformJson.root.modules = [{
name: 'fakePlugin2',
file: 'plugins/fakeId/www/fakeModule.js'
}];
-
+
platformJson.addPluginMetadata(fakePlugin);
expect(platformJson.root.modules.length).toBe(1);
expect(platformJson.root.modules[0].name).toBe('fakePlugin2');
});
-
+
it('Test 005 : should add entry to plugin_metadata with corresponding version', function () {
platformJson.addPluginMetadata(fakePlugin);
expect(platformJson.root.plugin_metadata[fakePlugin.id]).toBe(fakePlugin.version);
});
});
-
+
describe('removePluginMetadata method', function () {
it('Test 006 : should not throw if root "modules" property is missing', function () {
expect(function () {
platformJson.removePluginMetadata(fakePlugin);
}).not.toThrow();
});
-
+
it('Test 007 : should remove plugin modules from "root.modules" array based on file path', function () {
-
+
var pluginPaths = [
'plugins/fakeId/www/fakeModule.js',
'plugins/otherPlugin/www/module1.js',
'plugins/otherPlugin/www/module1.js'
];
-
+
platformJson.root.modules = pluginPaths.map(function (p) { return {file: p}; });
platformJson.removePluginMetadata(fakePlugin);
var resultantPaths = platformJson.root.modules
.map(function (p) { return p.file; })
.filter(function (f) { return /fakeModule\.js$/.test(f); });
-
+
expect(resultantPaths.length).toBe(0);
});
-
+
it('Test 008 : should remove entry from plugin_metadata with corresponding version', function () {
platformJson.root.plugin_metadata = {};
platformJson.root.plugin_metadata[fakePlugin.id] = fakePlugin.version;
@@ -107,7 +107,7 @@ describe('PlatformJson class', function() {
expect(platformJson.root.plugin_metadata[fakePlugin.id]).not.toBeDefined();
});
});
-
+
describe('generateMetadata method', function () {
it('Test 009 : should generate text metadata containing list of installed modules', function () {
var meta = platformJson.addPluginMetadata(fakePlugin).generateMetadata();
@@ -123,36 +123,36 @@ describe('PlatformJson class', function() {
describe('ModuleMetadata class', function () {
it('Test 010 : should be constructable', function () {
var meta;
- expect(function name(params) {
+ expect(function name (params) {
meta = new ModuleMetadata('fakePlugin', {src: 'www/fakeModule.js'});
}).not.toThrow();
expect(meta instanceof ModuleMetadata).toBeTruthy();
});
-
+
it('Test 011 : should throw if either pluginId or jsModule argument isn\'t specified', function () {
expect(ModuleMetadata).toThrow();
- expect(function () { new ModuleMetadata('fakePlugin', {}); }).toThrow();
+ expect(function () { new ModuleMetadata('fakePlugin', {}); }).toThrow(); /* eslint no-new : 0 */
});
-
+
it('Test 012 : should guess module id either from name property of from module src', function () {
expect(new ModuleMetadata('fakePlugin', {name: 'fakeModule'}).id).toMatch(/fakeModule$/);
expect(new ModuleMetadata('fakePlugin', {src: 'www/fakeModule.js'}).id).toMatch(/fakeModule$/);
});
-
+
it('Test 013 : should read "clobbers" property from module', function () {
expect(new ModuleMetadata('fakePlugin', {name: 'fakeModule'}).clobbers).not.toBeDefined();
var metadata = new ModuleMetadata('fakePlugin', FAKE_MODULE);
expect(metadata.clobbers).toEqual(jasmine.any(Array));
expect(metadata.clobbers[0]).toBe(FAKE_MODULE.clobbers[0].target);
});
-
+
it('Test 014 : should read "merges" property from module', function () {
expect(new ModuleMetadata('fakePlugin', {name: 'fakeModule'}).merges).not.toBeDefined();
var metadata = new ModuleMetadata('fakePlugin', FAKE_MODULE);
expect(metadata.merges).toEqual(jasmine.any(Array));
expect(metadata.merges[0]).toBe(FAKE_MODULE.merges[0].target);
});
-
+
it('Test 015 : should read "runs" property from module', function () {
expect(new ModuleMetadata('fakePlugin', {name: 'fakeModule'}).runs).not.toBeDefined();
expect(new ModuleMetadata('fakePlugin', FAKE_MODULE).runs).toBe(true);
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/PluginInfo/PluginInfo.spec.js
----------------------------------------------------------------------
diff --git a/spec/PluginInfo/PluginInfo.spec.js b/spec/PluginInfo/PluginInfo.spec.js
index e509913..f35147d 100644
--- a/spec/PluginInfo/PluginInfo.spec.js
+++ b/spec/PluginInfo/PluginInfo.spec.js
@@ -17,13 +17,14 @@
under the License.
*/
-var PluginInfo = require('../../src/PluginInfo/PluginInfo'),
- path = require('path');
+var PluginInfo = require('../../src/PluginInfo/PluginInfo');
+var path = require('path');
var pluginsDir = path.join(__dirname, '../fixtures/plugins');
describe('PluginInfo', function () {
it('Test 001 : should read a plugin.xml file', function () {
+ /* eslint-disable no-unused-vars */
var p, prefs, assets, deps, configFiles, infos, srcFiles;
var headerFiles, libFiles, resourceFiles;
expect(function () {
@@ -41,10 +42,11 @@ describe('PluginInfo', function () {
expect(p).toBeDefined();
expect(p.name).toEqual('Child Browser');
// TODO: Add some expectations for results of getSomething.
+ /* eslint-enable no-unused-vars */
});
it('Test 002 : should throw when there is no plugin.xml file', function () {
expect(function () {
- new PluginInfo('/non/existent/dir');
+ new PluginInfo('/non/existent/dir'); /* eslint no-new : 0 */
}).toThrow();
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/PluginInfo/PluginInfoProvider.spec.js
----------------------------------------------------------------------
diff --git a/spec/PluginInfo/PluginInfoProvider.spec.js b/spec/PluginInfo/PluginInfoProvider.spec.js
index 9c86501..b5425f5 100644
--- a/spec/PluginInfo/PluginInfoProvider.spec.js
+++ b/spec/PluginInfo/PluginInfoProvider.spec.js
@@ -17,8 +17,8 @@
under the License.
*/
-var PluginInfoProvider = require('../../src/PluginInfo/PluginInfoProvider'),
- path = require('path');
+var PluginInfoProvider = require('../../src/PluginInfo/PluginInfoProvider');
+var path = require('path');
var pluginsDir = path.join(__dirname, '../fixtures/plugins');
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/PluginManager.spec.js
----------------------------------------------------------------------
diff --git a/spec/PluginManager.spec.js b/spec/PluginManager.spec.js
index 7f6d7e8..1cea782 100644
--- a/spec/PluginManager.spec.js
+++ b/spec/PluginManager.spec.js
@@ -18,7 +18,7 @@
*/
// Promise-matchers do not work with jasmine 2.0.
-//require('promise-matchers');
+// require('promise-matchers');
var Q = require('q');
var fs = require('fs');
@@ -37,7 +37,7 @@ var FAKE_LOCATIONS = {
www: '/some/www/dir'
};
-describe('PluginManager class', function() {
+describe('PluginManager class', function () {
beforeEach(function () {
spyOn(ConfigChanges, 'PlatformMunger');
@@ -86,19 +86,19 @@ describe('PluginManager class', function() {
it('Test 004 : should iterate through all plugin\'s files and frameworks', function (done) {
manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})
- .then(function () {
- expect(FAKE_PROJECT.getInstaller.calls.count()).toBe(16);
- expect(FAKE_PROJECT.getUninstaller.calls.count()).toBe(16);
-
- expect(actions.push.calls.count()).toBe(16);
- expect(actions.process).toHaveBeenCalled();
- expect(FAKE_PROJECT.write).toHaveBeenCalled();
- })
- .fail(fail)
- .done(function () {
- expect(fail).not.toHaveBeenCalled();
- done();
- });
+ .then(function () {
+ expect(FAKE_PROJECT.getInstaller.calls.count()).toBe(16);
+ expect(FAKE_PROJECT.getUninstaller.calls.count()).toBe(16);
+
+ expect(actions.push.calls.count()).toBe(16);
+ expect(actions.process).toHaveBeenCalled();
+ expect(FAKE_PROJECT.write).toHaveBeenCalled();
+ })
+ .fail(fail)
+ .done(function () {
+ expect(fail).not.toHaveBeenCalled();
+ done();
+ });
});
it('Test 005 : should save plugin metadata to www directory', function (done) {
@@ -106,15 +106,15 @@ describe('PluginManager class', function() {
var platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {})
- .then(function () {
- expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8');
- expect(fs.writeFileSync).not.toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8');
- })
- .fail(fail)
- .done(function () {
- expect(fail).not.toHaveBeenCalled();
- done();
- });
+ .then(function () {
+ expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8');
+ expect(fs.writeFileSync).not.toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8');
+ })
+ .fail(fail)
+ .done(function () {
+ expect(fail).not.toHaveBeenCalled();
+ done();
+ });
});
it('Test 006 : should save plugin metadata to both www ans platform_www directories when options.usePlatformWww is specified', function (done) {
@@ -122,15 +122,15 @@ describe('PluginManager class', function() {
var platformWwwMetadataPath = path.join(manager.locations.platformWww, 'cordova_plugins.js');
manager.addPlugin(new PluginInfo(DUMMY_PLUGIN), {usePlatformWww: true})
- .then(function () {
- expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8');
- expect(fs.writeFileSync).toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8');
- })
- .fail(fail)
- .done(function () {
- expect(fail).not.toHaveBeenCalled();
- done();
- });
+ .then(function () {
+ expect(fs.writeFileSync).toHaveBeenCalledWith(metadataPath, jasmine.any(String), 'utf-8');
+ expect(fs.writeFileSync).toHaveBeenCalledWith(platformWwwMetadataPath, jasmine.any(String), 'utf-8');
+ })
+ .fail(fail)
+ .done(function () {
+ expect(fail).not.toHaveBeenCalled();
+ done();
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/events.spec.js
----------------------------------------------------------------------
diff --git a/spec/events.spec.js b/spec/events.spec.js
index 863664c..08a5498 100644
--- a/spec/events.spec.js
+++ b/spec/events.spec.js
@@ -20,11 +20,11 @@
var events = require('../src/events');
describe('forwardEventsTo method', function () {
- afterEach(function() {
+ afterEach(function () {
events.forwardEventsTo(null);
});
it('Test 001 : should not go to infinite loop when trying to forward to self', function () {
- expect(function() {
+ expect(function () {
events.forwardEventsTo(events);
events.emit('log', 'test message');
}).not.toThrow();
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/plist-helpers.spec.js
----------------------------------------------------------------------
diff --git a/spec/plist-helpers.spec.js b/spec/plist-helpers.spec.js
index 7b8cdbc..7c3b35a 100644
--- a/spec/plist-helpers.spec.js
+++ b/spec/plist-helpers.spec.js
@@ -1,8 +1,7 @@
var plistHelpers = require('../src/util/plist-helpers');
-
-describe('prunePLIST', function() {
- var doc = {
+describe('prunePLIST', function () {
+ var doc = {
FirstConfigKey: {
FirstPreferenceName: '*',
SecondPreferenceName: 'a + b',
@@ -16,16 +15,16 @@ describe('prunePLIST', function() {
var xml = '<dict>' +
'<key>FirstPreferenceName</key>' +
- '<string>*</string>' +
+ '<string>*</string>' +
'<key>SecondPreferenceName</key>' +
- '<string>a + b</string>' +
+ '<string>a + b</string>' +
'<key>ThirdPreferenceName</key>' +
- '<string>x-msauth-$(CFBundleIdentifier:rfc1034identifier)</string>' +
+ '<string>x-msauth-$(CFBundleIdentifier:rfc1034identifier)</string>' +
'</dict>';
var selector = 'FirstConfigKey';
- it('Test 01: should remove property from plist file using provided selector', function(done) {
+ it('Test 01: should remove property from plist file using provided selector', function (done) {
var pruneStatus = plistHelpers.prunePLIST(doc, xml, selector);
expect(pruneStatus).toBeTruthy();
@@ -39,4 +38,4 @@ describe('prunePLIST', function() {
done();
});
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/superspawn.spec.js
----------------------------------------------------------------------
diff --git a/spec/superspawn.spec.js b/spec/superspawn.spec.js
index 104073b..2a9729c 100644
--- a/spec/superspawn.spec.js
+++ b/spec/superspawn.spec.js
@@ -22,12 +22,12 @@ var superspawn = require('../src/superspawn');
var LS = process.platform === 'win32' ? 'dir' : 'ls';
-describe('spawn method', function() {
+describe('spawn method', function () {
var progressSpy, failSpy;
beforeEach(function () {
progressSpy = jasmine.createSpy('progress');
- failSpy = jasmine.createSpy('fail');
+ failSpy = jasmine.createSpy('fail'); /* eslint no-unused-vars : 0 */
});
it('Test 001 : should return a promise', function () {
@@ -37,55 +37,55 @@ describe('spawn method', function() {
it('Test 002 : should notify about stdout "data" events', function (done) {
superspawn.spawn(LS, [], {stdio: 'pipe'})
- .progress(progressSpy)
- .fin(function () {
- expect(progressSpy).toHaveBeenCalledWith({'stdout': jasmine.any(String)});
- done();
- });
+ .progress(progressSpy)
+ .fin(function () {
+ expect(progressSpy).toHaveBeenCalledWith({'stdout': jasmine.any(String)});
+ done();
+ });
});
it('Test 003 : should notify about stderr "data" events', function (done) {
superspawn.spawn(LS, ['doesnt-exist'], {stdio: 'pipe'})
- .progress(progressSpy)
- .fin(function () {
- expect(progressSpy).toHaveBeenCalledWith({'stderr': jasmine.any(String)});
- done();
- });
+ .progress(progressSpy)
+ .fin(function () {
+ expect(progressSpy).toHaveBeenCalledWith({'stderr': jasmine.any(String)});
+ done();
+ });
});
- it('Test 004 : reject handler should pass in Error object with stdout and stderr properties', function(done) {
+ it('Test 004 : reject handler should pass in Error object with stdout and stderr properties', function (done) {
var cp = require('child_process');
- spyOn(cp, 'spawn').and.callFake(function(cmd, args, opts) {
+ spyOn(cp, 'spawn').and.callFake(function (cmd, args, opts) {
return {
- stdout:{
- setEncoding: function(){},
- on: function(evt, handler) {
+ stdout: {
+ setEncoding: function () {},
+ on: function (evt, handler) {
// some sample stdout output
handler('business as usual');
}
},
- stderr:{
- setEncoding: function(){},
- on: function(evt, handler) {
+ stderr: {
+ setEncoding: function () {},
+ on: function (evt, handler) {
// some sample stderr output
handler('mayday mayday');
}
},
- on: function(evt, handler) {
+ on: function (evt, handler) {
// What's passed to handler here is the exit code, so we can control
// resolve/reject flow via this argument.
handler(1); // this will trigger error flow
},
- removeListener: function() {}
+ removeListener: function () {}
};
});
superspawn.spawn('this aggression', ['will', 'not', 'stand', 'man'], {})
- .catch(function(err) {
- expect(err).toBeDefined();
- expect(err.stdout).toContain('usual');
- expect(err.stderr).toContain('mayday');
- done();
- });
+ .catch(function (err) {
+ expect(err).toBeDefined();
+ expect(err.stdout).toContain('usual');
+ expect(err.stderr).toContain('mayday');
+ done();
+ });
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/util/xml-helpers.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/xml-helpers.spec.js b/spec/util/xml-helpers.spec.js
index 916e9af..f4d5fbc 100644
--- a/spec/util/xml-helpers.spec.js
+++ b/spec/util/xml-helpers.spec.js
@@ -17,22 +17,24 @@
under the License.
*/
-/* jshint laxcomma: true, multistr: true */
-
-var path = require('path')
- , xml_helpers = require('../../src/util/xml-helpers')
- , et = require('elementtree')
-
- , title = et.XML('<title>HELLO</title>')
- , usesNetworkOne = et.XML('<uses-permission ' +
- 'android:name="PACKAGE_NAME.permission.C2D_MESSAGE"/>')
- , usesNetworkTwo = et.XML('<uses-permission android:name=\
- "PACKAGE_NAME.permission.C2D_MESSAGE" />')
- , usesReceive = et.XML('<uses-permission android:name=\
- "com.google.android.c2dm.permission.RECEIVE"/>')
- , helloTagOne = et.XML('<h1>HELLO</h1>')
- , goodbyeTag = et.XML('<h1>GOODBYE</h1>')
- , helloTagTwo = et.XML('<h1> HELLO </h1>');
+/* eslint no-useless-escape : 0 */
+
+var path = require('path');
+var xml_helpers = require('../../src/util/xml-helpers');
+var et = require('elementtree');
+
+/* eslint-disable no-multi-str */
+
+var title = et.XML('<title>HELLO</title>');
+var usesNetworkOne = et.XML('<uses-permission ' +
+ 'android:name="PACKAGE_NAME.permission.C2D_MESSAGE"/>');
+var usesNetworkTwo = et.XML('<uses-permission android:name=\
+ "PACKAGE_NAME.permission.C2D_MESSAGE" />');
+var usesReceive = et.XML('<uses-permission android:name=\
+ "com.google.android.c2dm.permission.RECEIVE"/>');
+var helloTagOne = et.XML('<h1>HELLO</h1>');
+var goodbyeTag = et.XML('<h1>GOODBYE</h1>');
+var helloTagTwo = et.XML('<h1> HELLO </h1>');
var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<widget xmlns = "http://www.w3.org/ns/widgets"\n' +
@@ -52,90 +54,92 @@ var TEST_XML = '<?xml version="1.0" encoding="UTF-8"?>\n' +
' <preference name="webviewbounce" value="true" />\n' +
'</widget>\n';
-describe('xml-helpers', function(){
- describe('parseElementtreeSync', function() {
- it('Test 001 : should parse xml with a byte order mark', function() {
+/* eslint-enable no-multi-str */
+
+describe('xml-helpers', function () {
+ describe('parseElementtreeSync', function () {
+ it('Test 001 : should parse xml with a byte order mark', function () {
var xml_path = path.join(__dirname, '../fixtures/projects/windows/bom_test.xml');
- expect(function() {
+ expect(function () {
xml_helpers.parseElementtreeSync(xml_path);
}).not.toThrow();
});
});
- describe('equalNodes', function() {
- it('Test 002 : should return false for different tags', function(){
+ describe('equalNodes', function () {
+ it('Test 002 : should return false for different tags', function () {
expect(xml_helpers.equalNodes(usesNetworkOne, title)).toBe(false);
});
- it('Test 003 : should return true for identical tags', function(){
+ it('Test 003 : should return true for identical tags', function () {
expect(xml_helpers.equalNodes(usesNetworkOne, usesNetworkTwo)).toBe(true);
});
- it('Test 004 : should return false for different attributes', function(){
+ it('Test 004 : should return false for different attributes', function () {
expect(xml_helpers.equalNodes(usesNetworkOne, usesReceive)).toBe(false);
});
- it('Test 005 : should distinguish between text', function(){
+ it('Test 005 : should distinguish between text', function () {
expect(xml_helpers.equalNodes(helloTagOne, goodbyeTag)).toBe(false);
});
- it('Test 006 : should ignore whitespace in text', function(){
+ it('Test 006 : should ignore whitespace in text', function () {
expect(xml_helpers.equalNodes(helloTagOne, helloTagTwo)).toBe(true);
});
- describe('should compare children', function(){
- it('Test 007: by child quantity', function(){
- var one = et.XML('<i><b>o</b></i>'),
- two = et.XML('<i><b>o</b><u></u></i>');
+ describe('should compare children', function () {
+ it('Test 007: by child quantity', function () {
+ var one = et.XML('<i><b>o</b></i>');
+ var two = et.XML('<i><b>o</b><u></u></i>');
expect(xml_helpers.equalNodes(one, two)).toBe(false);
});
- it('Test 008 : by child equality', function(){
- var one = et.XML('<i><b>o</b></i>'),
- two = et.XML('<i><u></u></i>'),
- uno = et.XML('<i>\n<b>o</b>\n</i>');
+ it('Test 008 : by child equality', function () {
+ var one = et.XML('<i><b>o</b></i>');
+ var two = et.XML('<i><u></u></i>');
+ var uno = et.XML('<i>\n<b>o</b>\n</i>');
expect(xml_helpers.equalNodes(one, uno)).toBe(true);
expect(xml_helpers.equalNodes(one, two)).toBe(false);
});
});
});
- describe('pruneXML', function() {
+ describe('pruneXML', function () {
var config_xml;
- beforeEach(function() {
+ beforeEach(function () {
config_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/res/xml/config.xml'));
});
- it('Test 009 : should remove any children that match the specified selector', function() {
+ it('Test 009 : should remove any children that match the specified selector', function () {
var children = config_xml.findall('plugins/plugin');
xml_helpers.pruneXML(config_xml, children, 'plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(0);
});
- it('Test 010 : should do nothing if the children cannot be found', function() {
+ it('Test 010 : should do nothing if the children cannot be found', function () {
var children = [title];
xml_helpers.pruneXML(config_xml, children, 'plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(17);
});
- it('Test 011 : should be able to handle absolute selectors', function() {
+ it('Test 011 : should be able to handle absolute selectors', function () {
var children = config_xml.findall('plugins/plugin');
xml_helpers.pruneXML(config_xml, children, '/cordova/plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(0);
});
- it('Test 012 : should be able to handle absolute selectors with wildcards', function() {
+ it('Test 012 : should be able to handle absolute selectors with wildcards', function () {
var children = config_xml.findall('plugins/plugin');
xml_helpers.pruneXML(config_xml, children, '/*/plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(0);
});
});
- describe('pruneXMLRestore', function() {
+ describe('pruneXMLRestore', function () {
var android_manifest_xml;
- beforeEach(function() {
+ beforeEach(function () {
android_manifest_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/AndroidManifest.xml'));
});
- it('Test 013 : should restore attributes at the specified selector', function() {
+ it('Test 013 : should restore attributes at the specified selector', function () {
var xml = {
oldAttrib: {'android:icon': '@drawable/icon', 'android:label': '@string/app_name', 'android:debuggable': 'false'}
};
@@ -144,7 +148,7 @@ describe('xml-helpers', function(){
expect(Object.keys(applicationAttr).length).toEqual(3);
expect(applicationAttr['android:debuggable']).toEqual('false');
});
- it('Test 014 : should do nothing if the old attributes cannot be found', function() {
+ it('Test 014 : should do nothing if the old attributes cannot be found', function () {
var xml = {
notOldAttrib: {'android:icon': '@drawable/icon', 'android:label': '@string/app_name', 'android:debuggable': 'false'}
};
@@ -153,7 +157,7 @@ describe('xml-helpers', function(){
expect(Object.keys(applicationAttr).length).toEqual(3);
expect(applicationAttr['android:debuggable']).toEqual('true');
});
- it('Test 015 : should be able to handle absolute selectors', function() {
+ it('Test 015 : should be able to handle absolute selectors', function () {
var xml = {
oldAttrib: {'android:icon': '@drawable/icon', 'android:label': '@string/app_name', 'android:debuggable': 'false'}
};
@@ -162,7 +166,7 @@ describe('xml-helpers', function(){
expect(Object.keys(applicationAttr).length).toEqual(3);
expect(applicationAttr['android:debuggable']).toEqual('false');
});
- it('Test 016 : should be able to handle absolute selectors with wildcards', function() {
+ it('Test 016 : should be able to handle absolute selectors with wildcards', function () {
var xml = {
oldAttrib: {'android:name': 'ChildApp', 'android:label': '@string/app_name', 'android:configChanges': 'orientation|keyboardHidden', 'android:enabled': 'true'}
};
@@ -171,7 +175,7 @@ describe('xml-helpers', function(){
expect(Object.keys(activityAttr).length).toEqual(4);
expect(activityAttr['android:enabled']).toEqual('true');
});
- it('Test 017 : should be able to handle xpath selectors', function() {
+ it('Test 017 : should be able to handle xpath selectors', function () {
var xml = {
oldAttrib: {'android:name': 'com.phonegap.DroidGap', 'android:label': '@string/app_name', 'android:configChanges': 'orientation|keyboardHidden', 'android:enabled': 'true'}
};
@@ -182,39 +186,39 @@ describe('xml-helpers', function(){
});
});
- describe('graftXML', function() {
+ describe('graftXML', function () {
var config_xml, plugin_xml;
- beforeEach(function() {
+ beforeEach(function () {
config_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/res/xml/config.xml'));
plugin_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/plugins/ChildBrowser/plugin.xml'));
});
- it('Test 018 : should add children to the specified selector', function() {
+ it('Test 018 : should add children to the specified selector', function () {
var children = plugin_xml.find('config-file').getchildren();
xml_helpers.graftXML(config_xml, children, 'plugins');
expect(config_xml.find('plugins').getchildren().length).toEqual(19);
});
- it('Test 019 : should be able to handle absolute selectors', function() {
+ it('Test 019 : should be able to handle absolute selectors', function () {
var children = plugin_xml.find('config-file').getchildren();
xml_helpers.graftXML(config_xml, children, '/cordova');
expect(config_xml.findall('access').length).toEqual(3);
});
- it('Test 020 : should be able to handle absolute selectors with wildcards', function() {
+ it('Test 020 : should be able to handle absolute selectors with wildcards', function () {
var children = plugin_xml.find('config-file').getchildren();
xml_helpers.graftXML(config_xml, children, '/*');
expect(config_xml.findall('access').length).toEqual(3);
});
});
- describe('graftXMLMerge', function() {
+ describe('graftXMLMerge', function () {
var plugin_xml, android_manifest_xml;
- beforeEach(function() {
+ beforeEach(function () {
plugin_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest/plugin.xml'));
android_manifest_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/AndroidManifest.xml'));
});
- it ('Test 021 : should merge attributes at specified selector', function() {
+ it('Test 021 : should merge attributes at specified selector', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"merge\"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, 'application/activity[@android:name=\"com.phonegap.DroidGap\"]', {});
var activityAttr = android_manifest_xml.find('application/activity[@android:name=\"com.phonegap.DroidGap\"]').attrib;
@@ -222,7 +226,7 @@ describe('xml-helpers', function(){
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).toEqual('keyboardHidden');
});
- it ('Test 022 : should be able to handle absolute selectors', function() {
+ it('Test 022 : should be able to handle absolute selectors', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"merge\"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, '/manifest/application/activity[@android:name=\"com.phonegap.DroidGap\"]', {});
var activityAttr = android_manifest_xml.find('application/activity[@android:name=\"com.phonegap.DroidGap\"]').attrib;
@@ -230,7 +234,7 @@ describe('xml-helpers', function(){
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).toEqual('keyboardHidden');
});
- it ('Test 023 : should be able to handle absolute selectors with wildcards', function() {
+ it('Test 023 : should be able to handle absolute selectors with wildcards', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"merge\"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, '/*/*/activity[@android:name=\"com.phonegap.DroidGap\"]', {});
var activityAttr = android_manifest_xml.find('application/activity[@android:name=\"com.phonegap.DroidGap\"]').attrib;
@@ -238,7 +242,7 @@ describe('xml-helpers', function(){
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).toEqual('keyboardHidden');
});
- it ('Test 024 : should be able to handle xpath selectors', function() {
+ it('Test 024 : should be able to handle xpath selectors', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"merge\"]').getchildren();
xml_helpers.graftXMLMerge(android_manifest_xml, children, 'application/activity[@android:name=\"com.phonegap.DroidGap\"]', {});
var activityAttr = android_manifest_xml.find('application/activity[@android:name=\"com.phonegap.DroidGap\"]').attrib;
@@ -248,14 +252,14 @@ describe('xml-helpers', function(){
});
});
- describe('graftXMLOverwrite', function() {
+ describe('graftXMLOverwrite', function () {
var plugin_xml, android_manifest_xml;
- beforeEach(function() {
+ beforeEach(function () {
plugin_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest/plugin.xml'));
android_manifest_xml = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/projects/android/AndroidManifest.xml'));
});
- it ('Test 025 : should overwrite attributes at specified selector', function() {
+ it('Test 025 : should overwrite attributes at specified selector', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"overwrite\"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, 'application/activity', {});
var activityAttr = android_manifest_xml.find('application/activity').attrib;
@@ -263,7 +267,7 @@ describe('xml-helpers', function(){
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).not.toBeDefined();
});
- it ('Test 026 : should be able to handle absolute selectors', function() {
+ it('Test 026 : should be able to handle absolute selectors', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"overwrite\"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, '/manifest/application/activity', {});
var activityAttr = android_manifest_xml.find('application/activity').attrib;
@@ -271,7 +275,7 @@ describe('xml-helpers', function(){
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).not.toBeDefined();
});
- it ('Test 027 : should be able to handle absolute selectors with wildcards', function() {
+ it('Test 027 : should be able to handle absolute selectors with wildcards', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"overwrite\"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, '/*/*/activity', {});
var activityAttr = android_manifest_xml.find('application/activity').attrib;
@@ -279,7 +283,7 @@ describe('xml-helpers', function(){
expect(activityAttr['android:enabled']).toEqual('true');
expect(activityAttr['android:configChanges']).not.toBeDefined();
});
- it ('Test 028 : should be able to handle xpath selectors', function() {
+ it('Test 028 : should be able to handle xpath selectors', function () {
var children = plugin_xml.find('platform/edit-config[@mode=\"overwrite\"]').getchildren();
xml_helpers.graftXMLOverwrite(android_manifest_xml, children, 'application/activity[@android:name=\"ChildApp\"]', {});
var activityAttr = android_manifest_xml.find('application/activity').attrib;
@@ -291,7 +295,7 @@ describe('xml-helpers', function(){
describe('mergeXml', function () {
var dstXml;
- beforeEach(function() {
+ beforeEach(function () {
dstXml = et.XML(TEST_XML);
});
@@ -321,16 +325,16 @@ describe('xml-helpers', function(){
});
it('Test 032 : should not merge platform tags with the wrong platform', function () {
- var testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>'),
- origCfg = et.tostring(dstXml);
+ var testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>');
+ var origCfg = et.tostring(dstXml);
xml_helpers.mergeXml(testXml, dstXml, 'foo', true);
expect(et.tostring(dstXml)).toEqual(origCfg);
});
it('Test 033 : should merge platform tags with the correct platform', function () {
- var testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>'),
- origCfg = et.tostring(dstXml);
+ var testXml = et.XML('<widget><platform name="bar"><testElement testAttrib="value">testTEXT</testElement></platform></widget>');
+ var origCfg = et.tostring(dstXml);
xml_helpers.mergeXml(testXml, dstXml, 'bar', true);
expect(et.tostring(dstXml)).not.toEqual(origCfg);
@@ -413,19 +417,19 @@ describe('xml-helpers', function(){
});
it('Test 041 : should not skip partial duplicate non singelton children', function () {
- //remove access tags from dstXML
+ // remove access tags from dstXML
var testElements = dstXml.findall('access');
- for(var i = 0; i < testElements.length; i++) {
+ for (var i = 0; i < testElements.length; i++) {
dstXml.remove(testElements[i]);
}
testElements = dstXml.findall('access');
expect(testElements.length).toEqual(0);
- //add an external whitelist access tag
+ // add an external whitelist access tag
var testXml = et.XML('<widget><access origin="*" launch-external="yes"/></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
testElements = dstXml.findall('access');
expect(testElements.length).toEqual(1);
- //add an internal whitelist access tag
+ // add an internal whitelist access tag
testXml = et.XML('<widget><access origin="*"/></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
testElements = dstXml.findall('access');
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/.jshintrc
----------------------------------------------------------------------
diff --git a/src/.jshintrc b/src/.jshintrc
deleted file mode 100644
index 89a121c..0000000
--- a/src/.jshintrc
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "node": true
- , "bitwise": true
- , "undef": true
- , "trailing": true
- , "quotmark": true
- , "indent": 4
- , "unused": "vars"
- , "latedef": "nofunc"
-}
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/ActionStack.js
----------------------------------------------------------------------
diff --git a/src/ActionStack.js b/src/ActionStack.js
index 5ef6f84..6983c5c 100644
--- a/src/ActionStack.js
+++ b/src/ActionStack.js
@@ -19,32 +19,32 @@
/* jshint quotmark:false */
-var events = require('./events'),
- Q = require('q');
+var events = require('./events');
+var Q = require('q');
-function ActionStack() {
+function ActionStack () {
this.stack = [];
this.completed = [];
}
ActionStack.prototype = {
- createAction:function(handler, action_params, reverter, revert_params) {
+ createAction: function (handler, action_params, reverter, revert_params) {
return {
- handler:{
- run:handler,
- params:action_params
+ handler: {
+ run: handler,
+ params: action_params
},
- reverter:{
- run:reverter,
- params:revert_params
+ reverter: {
+ run: reverter,
+ params: revert_params
}
};
},
- push:function(tx) {
+ push: function (tx) {
this.stack.push(tx);
},
// Returns a promise.
- process:function(platform) {
+ process: function (platform) {
events.emit('verbose', 'Beginning processing of action stack for ' + platform + ' project...');
while (this.stack.length) {
@@ -54,19 +54,19 @@ ActionStack.prototype = {
try {
handler.apply(null, action_params);
- } catch(e) {
+ } catch (e) {
events.emit('warn', 'Error during processing of action! Attempting to revert...');
this.stack.unshift(action);
var issue = 'Uh oh!\n';
// revert completed tasks
- while(this.completed.length) {
+ while (this.completed.length) {
var undo = this.completed.shift();
var revert = undo.reverter.run;
var revert_params = undo.reverter.params;
try {
revert.apply(null, revert_params);
- } catch(err) {
+ } catch (err) {
events.emit('warn', 'Error during reversion of action! We probably really messed up your project now, sorry! D:');
issue += 'A reversion action failed: ' + err.message + '\n';
}
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/ConfigChanges/ConfigChanges.js
----------------------------------------------------------------------
diff --git a/src/ConfigChanges/ConfigChanges.js b/src/ConfigChanges/ConfigChanges.js
index 4a58132..f0cf8d9 100644
--- a/src/ConfigChanges/ConfigChanges.js
+++ b/src/ConfigChanges/ConfigChanges.js
@@ -15,7 +15,7 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-*/
+*/
/*
* This module deals with shared configuration / dependency "stuff". That is:
@@ -29,19 +29,17 @@
* reference counts.
*/
-/* jshint sub:true */
-
-var path = require('path'),
- et = require('elementtree'),
- ConfigKeeper = require('./ConfigKeeper'),
- CordovaLogger = require('../CordovaLogger');
+var path = require('path');
+var et = require('elementtree');
+var ConfigKeeper = require('./ConfigKeeper');
+var CordovaLogger = require('../CordovaLogger');
var mungeutil = require('./munge-util');
var xml_helpers = require('../util/xml-helpers');
exports.PlatformMunger = PlatformMunger;
-exports.process = function(plugins_dir, project_dir, platform, platformJson, pluginInfoProvider) {
+exports.process = function (plugins_dir, project_dir, platform, platformJson, pluginInfoProvider) {
var munger = new PlatformMunger(platform, project_dir, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
munger.save_all();
@@ -53,7 +51,7 @@ exports.process = function(plugins_dir, project_dir, platform, platformJson, plu
* Can deal with config file of a single project.
* Parsed config files are cached in a ConfigKeeper object.
******************************************************************************/
-function PlatformMunger(platform, project_dir, platformJson, pluginInfoProvider) {
+function PlatformMunger (platform, project_dir, platformJson, pluginInfoProvider) {
this.platform = platform;
this.project_dir = project_dir;
this.config_keeper = new ConfigKeeper(project_dir);
@@ -63,7 +61,7 @@ function PlatformMunger(platform, project_dir, platformJson, pluginInfoProvider)
// Write out all unsaved files.
PlatformMunger.prototype.save_all = PlatformMunger_save_all;
-function PlatformMunger_save_all() {
+function PlatformMunger_save_all () {
this.config_keeper.save_all();
this.platformJson.save();
}
@@ -71,7 +69,7 @@ function PlatformMunger_save_all() {
// Apply a munge object to a single config file.
// The remove parameter tells whether to add the change or remove it.
PlatformMunger.prototype.apply_file_munge = PlatformMunger_apply_file_munge;
-function PlatformMunger_apply_file_munge(file, munge, remove) {
+function PlatformMunger_apply_file_munge (file, munge, remove) {
var self = this;
for (var selector in munge.parents) {
@@ -86,16 +84,15 @@ function PlatformMunger_apply_file_munge(file, munge, remove) {
}
}
-
PlatformMunger.prototype.remove_plugin_changes = remove_plugin_changes;
-function remove_plugin_changes(pluginInfo, is_top_level) {
+function remove_plugin_changes (pluginInfo, is_top_level) {
var self = this;
var platform_config = self.platformJson.root;
var plugin_vars = is_top_level ?
platform_config.installed_plugins[pluginInfo.id] :
platform_config.dependent_plugins[pluginInfo.id];
var edit_config_changes = null;
- if(pluginInfo.getEditConfigs) {
+ if (pluginInfo.getEditConfigs) {
edit_config_changes = pluginInfo.getEditConfigs(self.platform);
}
@@ -114,14 +111,13 @@ function remove_plugin_changes(pluginInfo, is_top_level) {
return self;
}
-
PlatformMunger.prototype.add_plugin_changes = add_plugin_changes;
-function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increment, plugin_force) {
+function add_plugin_changes (pluginInfo, plugin_vars, is_top_level, should_increment, plugin_force) {
var self = this;
var platform_config = self.platformJson.root;
var edit_config_changes = null;
- if(pluginInfo.getEditConfigs) {
+ if (pluginInfo.getEditConfigs) {
edit_config_changes = pluginInfo.getEditConfigs(self.platform);
}
@@ -130,8 +126,7 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm
if (!edit_config_changes || edit_config_changes.length === 0) {
// get config munge, aka how should this plugin change various config files
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars);
- }
- else {
+ } else {
var isConflictingInfo = is_conflicting(edit_config_changes, platform_config.config_munge, self, plugin_force);
if (isConflictingInfo.conflictWithConfigxml) {
@@ -149,13 +144,11 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm
// force add new munges
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars, edit_config_changes);
- }
- else if(isConflictingInfo.conflictFound) {
+ } else if (isConflictingInfo.conflictFound) {
throw new Error('There was a conflict trying to modify attributes with <edit-config> in plugin ' + pluginInfo.id +
'. The conflicting plugin, ' + isConflictingInfo.conflictingPlugin + ', already modified the same attributes. The conflict must be resolved before ' +
pluginInfo.id + ' can be added. You may use --force to add the plugin and overwrite the conflicting attributes.');
- }
- else {
+ } else {
// no conflicts, will handle edit-config
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars, edit_config_changes);
}
@@ -168,27 +161,25 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm
return self;
}
-
// Handle edit-config changes from config.xml
PlatformMunger.prototype.add_config_changes = add_config_changes;
-function add_config_changes(config, should_increment) {
+function add_config_changes (config, should_increment) {
var self = this;
var platform_config = self.platformJson.root;
var config_munge;
var edit_config_changes = null;
- if(config.getEditConfigs) {
+ if (config.getEditConfigs) {
edit_config_changes = config.getEditConfigs(self.platform);
}
if (!edit_config_changes || edit_config_changes.length === 0) {
// There are no edit-config changes to add, return here
return self;
- }
- else {
- var isConflictingInfo = is_conflicting(edit_config_changes, platform_config.config_munge, self, true /*always force overwrite other edit-config*/);
+ } else {
+ var isConflictingInfo = is_conflicting(edit_config_changes, platform_config.config_munge, self, true /* always force overwrite other edit-config */);
- if(isConflictingInfo.conflictFound) {
+ if (isConflictingInfo.conflictFound) {
var conflict_munge;
var conflict_file;
@@ -219,7 +210,7 @@ function add_config_changes(config, should_increment) {
return self;
}
-function munge_helper(should_increment, self, platform_config, config_munge) {
+function munge_helper (should_increment, self, platform_config, config_munge) {
// global munge looks at all changes to config files
// TODO: The should_increment param is only used by cordova-cli and is going away soon.
@@ -241,11 +232,10 @@ function munge_helper(should_increment, self, platform_config, config_munge) {
return self;
}
-
// Load the global munge from platform json and apply all of it.
// Used by cordova prepare to re-generate some config file from platform
// defaults and the global munge.
-PlatformMunger.prototype.reapply_global_munge = reapply_global_munge ;
+PlatformMunger.prototype.reapply_global_munge = reapply_global_munge;
function reapply_global_munge () {
var self = this;
@@ -261,27 +251,26 @@ function reapply_global_munge () {
// generate_plugin_config_munge
// Generate the munge object from config.xml
PlatformMunger.prototype.generate_config_xml_munge = generate_config_xml_munge;
-function generate_config_xml_munge(config, edit_config_changes, type) {
+function generate_config_xml_munge (config, edit_config_changes, type) {
var munge = { files: {} };
var changes = edit_config_changes;
var id;
- if(!changes) {
+ if (!changes) {
return munge;
}
if (type === 'config.xml') {
id = type;
- }
- else {
+ } else {
id = config.id;
}
- changes.forEach(function(change) {
- change.xmls.forEach(function(xml) {
+ changes.forEach(function (change) {
+ change.xmls.forEach(function (xml) {
// 1. stringify each xml
- var stringified = (new et.ElementTree(xml)).write({xml_declaration:false});
+ var stringified = (new et.ElementTree(xml)).write({xml_declaration: false});
// 2. add into munge
if (change.mode) {
mungeutil.deep_add(munge, change.file, change.target, { xml: stringified, count: 1, mode: change.mode, id: id });
@@ -291,28 +280,27 @@ function generate_config_xml_munge(config, edit_config_changes, type) {
return munge;
}
-
// generate_plugin_config_munge
// Generate the munge object from plugin.xml + vars
PlatformMunger.prototype.generate_plugin_config_munge = generate_plugin_config_munge;
-function generate_plugin_config_munge(pluginInfo, vars, edit_config_changes) {
+function generate_plugin_config_munge (pluginInfo, vars, edit_config_changes) {
var self = this;
vars = vars || {};
var munge = { files: {} };
var changes = pluginInfo.getConfigFiles(self.platform);
- if(edit_config_changes) {
+ if (edit_config_changes) {
Array.prototype.push.apply(changes, edit_config_changes);
}
- changes.forEach(function(change) {
- change.xmls.forEach(function(xml) {
+ changes.forEach(function (change) {
+ change.xmls.forEach(function (xml) {
// 1. stringify each xml
- var stringified = (new et.ElementTree(xml)).write({xml_declaration:false});
+ var stringified = (new et.ElementTree(xml)).write({xml_declaration: false});
// interp vars
if (vars) {
- Object.keys(vars).forEach(function(key) {
+ Object.keys(vars).forEach(function (key) {
var regExp = new RegExp('\\$' + key, 'g');
stringified = stringified.replace(regExp, vars[key]);
});
@@ -322,8 +310,7 @@ function generate_plugin_config_munge(pluginInfo, vars, edit_config_changes) {
if (change.mode !== 'remove') {
mungeutil.deep_add(munge, change.file, change.target, { xml: stringified, count: 1, mode: change.mode, plugin: pluginInfo.id });
}
- }
- else {
+ } else {
mungeutil.deep_add(munge, change.target, change.parent, { xml: stringified, count: 1, after: change.after });
}
});
@@ -331,7 +318,7 @@ function generate_plugin_config_munge(pluginInfo, vars, edit_config_changes) {
return munge;
}
-function is_conflicting(editchanges, config_munge, self, force) {
+function is_conflicting (editchanges, config_munge, self, force) {
var files = config_munge.files;
var conflictFound = false;
var conflictWithConfigxml = false;
@@ -340,7 +327,7 @@ function is_conflicting(editchanges, config_munge, self, force) {
var conflictingParent;
var conflictingPlugin;
- editchanges.forEach(function(editchange) {
+ editchanges.forEach(function (editchange) {
if (files[editchange.file]) {
var parents = files[editchange.file].parents;
var target = parents[editchange.target];
@@ -361,8 +348,7 @@ function is_conflicting(editchanges, config_munge, self, force) {
}
}
}
- }
- else {
+ } else {
conflictingParent = editchange.target;
}
@@ -374,13 +360,11 @@ function is_conflicting(editchanges, config_munge, self, force) {
if (target[0].id === 'config.xml') {
// Keep track of config.xml/config.xml edit-config conflicts
mungeutil.deep_add(configxmlMunge, editchange.file, conflictingParent, target[0]);
- }
- else {
+ } else {
// Keep track of config.xml x plugin.xml edit-config conflicts
mungeutil.deep_add(conflictingMunge, editchange.file, conflictingParent, target[0]);
}
- }
- else {
+ } else {
if (target[0].id === 'config.xml') {
// plugin.xml cannot overwrite config.xml changes even if --force is used
conflictWithConfigxml = true;
@@ -390,36 +374,38 @@ function is_conflicting(editchanges, config_munge, self, force) {
if (force) {
// Need to find all conflicts when --force is used, track conflicting munges
mungeutil.deep_add(conflictingMunge, editchange.file, conflictingParent, target[0]);
- }
- else {
+ } else {
// plugin cannot overwrite other plugin changes without --force
conflictingPlugin = target[0].plugin;
- return;
+
}
}
}
}
});
- return {conflictFound: conflictFound, conflictingPlugin: conflictingPlugin, conflictingMunge: conflictingMunge,
- configxmlMunge: configxmlMunge, conflictWithConfigxml:conflictWithConfigxml};
+ return {conflictFound: conflictFound,
+ conflictingPlugin: conflictingPlugin,
+ conflictingMunge: conflictingMunge,
+ configxmlMunge: configxmlMunge,
+ conflictWithConfigxml: conflictWithConfigxml};
}
// Go over the prepare queue and apply the config munges for each plugin
// that has been (un)installed.
PlatformMunger.prototype.process = PlatformMunger_process;
-function PlatformMunger_process(plugins_dir) {
+function PlatformMunger_process (plugins_dir) {
var self = this;
var platform_config = self.platformJson.root;
// Uninstallation first
- platform_config.prepare_queue.uninstalled.forEach(function(u) {
+ platform_config.prepare_queue.uninstalled.forEach(function (u) {
var pluginInfo = self.pluginInfoProvider.get(path.join(plugins_dir, u.plugin));
self.remove_plugin_changes(pluginInfo, u.topLevel);
});
// Now handle installation
- platform_config.prepare_queue.installed.forEach(function(u) {
+ platform_config.prepare_queue.installed.forEach(function (u) {
var pluginInfo = self.pluginInfoProvider.get(path.join(plugins_dir, u.plugin));
self.add_plugin_changes(pluginInfo, u.vars, u.topLevel, true, u.force);
});
@@ -428,4 +414,4 @@ function PlatformMunger_process(plugins_dir) {
platform_config.prepare_queue.uninstalled = [];
platform_config.prepare_queue.installed = [];
}
-/**** END of PlatformMunger ****/
+/** ** END of PlatformMunger ****/
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/ConfigChanges/ConfigFile.js
----------------------------------------------------------------------
diff --git a/src/ConfigChanges/ConfigFile.js b/src/ConfigChanges/ConfigFile.js
index 8f880a4..a4a7331 100644
--- a/src/ConfigChanges/ConfigFile.js
+++ b/src/ConfigChanges/ConfigFile.js
@@ -14,6 +14,8 @@
*
*/
+/* eslint no-control-regex: 0 */
+
var fs = require('fs');
var path = require('path');
@@ -42,7 +44,7 @@ addProperty(module, 'xml_helpers', '../util/xml-helpers', modules);
* TODO: Consider moving it out to a separate file and maybe partially with
* overrides in platform handlers.
******************************************************************************/
-function ConfigFile(project_dir, platform, file_tag) {
+function ConfigFile (project_dir, platform, file_tag) {
this.project_dir = project_dir;
this.platform = platform;
this.file_tag = file_tag;
@@ -53,13 +55,13 @@ function ConfigFile(project_dir, platform, file_tag) {
// ConfigFile.load()
ConfigFile.prototype.load = ConfigFile_load;
-function ConfigFile_load() {
+function ConfigFile_load () {
var self = this;
// config file may be in a place not exactly specified in the target
var filepath = self.filepath = resolveConfigFilePath(self.project_dir, self.platform, self.file_tag);
- if ( !filepath || !fs.existsSync(filepath) ) {
+ if (!filepath || !fs.existsSync(filepath)) {
self.exists = false;
return;
}
@@ -69,7 +71,7 @@ function ConfigFile_load() {
var ext = path.extname(filepath);
// Windows8 uses an appxmanifest, and wp8 will likely use
// the same in a future release
- if (ext == '.xml' || ext == '.appxmanifest') {
+ if (ext === '.xml' || ext === '.appxmanifest') {
self.type = 'xml';
self.data = modules.xml_helpers.parseElementtreeSync(filepath);
} else {
@@ -80,12 +82,12 @@ function ConfigFile_load() {
// Do we still need to support binary plist?
// If yes, use plist.parseStringSync() and read the file once.
self.data = isBinaryPlist(filepath) ?
- modules.bplist.parseBuffer(fs.readFileSync(filepath)) :
- modules.plist.parse(fs.readFileSync(filepath, 'utf8'));
+ modules.bplist.parseBuffer(fs.readFileSync(filepath)) :
+ modules.plist.parse(fs.readFileSync(filepath, 'utf8'));
}
}
-ConfigFile.prototype.save = function ConfigFile_save() {
+ConfigFile.prototype.save = function ConfigFile_save () {
var self = this;
if (self.type === 'xml') {
fs.writeFileSync(self.filepath, self.data.write({indent: 4}), 'utf-8');
@@ -97,54 +99,54 @@ ConfigFile.prototype.save = function ConfigFile_save() {
self.is_changed = false;
};
-ConfigFile.prototype.graft_child = function ConfigFile_graft_child(selector, xml_child) {
+ConfigFile.prototype.graft_child = function ConfigFile_graft_child (selector, xml_child) {
var self = this;
var filepath = self.filepath;
var result;
if (self.type === 'xml') {
var xml_to_graft = [modules.et.XML(xml_child.xml)];
switch (xml_child.mode) {
- case 'merge':
- result = modules.xml_helpers.graftXMLMerge(self.data, xml_to_graft, selector, xml_child);
- break;
- case 'overwrite':
- result = modules.xml_helpers.graftXMLOverwrite(self.data, xml_to_graft, selector, xml_child);
- break;
- case 'remove':
- result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
- break;
- default:
- result = modules.xml_helpers.graftXML(self.data, xml_to_graft, selector, xml_child.after);
+ case 'merge':
+ result = modules.xml_helpers.graftXMLMerge(self.data, xml_to_graft, selector, xml_child);
+ break;
+ case 'overwrite':
+ result = modules.xml_helpers.graftXMLOverwrite(self.data, xml_to_graft, selector, xml_child);
+ break;
+ case 'remove':
+ result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
+ break;
+ default:
+ result = modules.xml_helpers.graftXML(self.data, xml_to_graft, selector, xml_child.after);
}
- if ( !result) {
+ if (!result) {
throw new Error('Unable to graft xml at selector "' + selector + '" from "' + filepath + '" during config install');
}
} else {
// plist file
result = modules.plist_helpers.graftPLIST(self.data, xml_child.xml, selector);
- if ( !result ) {
+ if (!result) {
throw new Error('Unable to graft plist "' + filepath + '" during config install');
}
}
self.is_changed = true;
};
-ConfigFile.prototype.prune_child = function ConfigFile_prune_child(selector, xml_child) {
+ConfigFile.prototype.prune_child = function ConfigFile_prune_child (selector, xml_child) {
var self = this;
var filepath = self.filepath;
var result;
if (self.type === 'xml') {
var xml_to_graft = [modules.et.XML(xml_child.xml)];
switch (xml_child.mode) {
- case 'merge':
- case 'overwrite':
- result = modules.xml_helpers.pruneXMLRestore(self.data, selector, xml_child);
- break;
- case 'remove':
- result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
- break;
- default:
- result = modules.xml_helpers.pruneXML(self.data, xml_to_graft, selector);
+ case 'merge':
+ case 'overwrite':
+ result = modules.xml_helpers.pruneXMLRestore(self.data, selector, xml_child);
+ break;
+ case 'remove':
+ result = modules.xml_helpers.pruneXMLRemove(self.data, selector, xml_to_graft);
+ break;
+ default:
+ result = modules.xml_helpers.pruneXML(self.data, xml_to_graft, selector);
}
} else {
// plist file
@@ -160,7 +162,7 @@ ConfigFile.prototype.prune_child = function ConfigFile_prune_child(selector, xml
// Some config-file target attributes are not qualified with a full leading directory, or contain wildcards.
// Resolve to a real path in this function.
// TODO: getIOSProjectname is slow because of glob, try to avoid calling it several times per project.
-function resolveConfigFilePath(project_dir, platform, file) {
+function resolveConfigFilePath (project_dir, platform, file) {
var filepath = path.join(project_dir, file);
var matches;
@@ -170,10 +172,10 @@ function resolveConfigFilePath(project_dir, platform, 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.indexOf('-Info.plist')>-1){
- var plistName = getIOSProjectname(project_dir)+'-Info.plist';
- for (var i=0; i < matches.length; i++) {
- if(matches[i].indexOf(plistName) > -1){
+ 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].indexOf(plistName) > -1) {
filepath = matches[i];
break;
}
@@ -184,13 +186,13 @@ function resolveConfigFilePath(project_dir, platform, file) {
// special-case config.xml target that is just "config.xml". This should be resolved to the real location of the file.
// TODO: move the logic that contains the locations of config.xml from cordova CLI into plugman.
- if (file == 'config.xml') {
- if (platform == 'ubuntu') {
+ if (file === 'config.xml') {
+ if (platform === 'ubuntu') {
filepath = path.join(project_dir, 'config.xml');
- } else if (platform == 'ios') {
+ } else if (platform === 'ios') {
var iospath = getIOSProjectname(project_dir);
- filepath = path.join(project_dir,iospath, 'config.xml');
- } else if (platform == 'android') {
+ filepath = path.join(project_dir, iospath, 'config.xml');
+ } else if (platform === 'android') {
filepath = path.join(project_dir, 'res', 'xml', 'config.xml');
} else {
matches = modules.glob.sync(path.join(project_dir, '**', 'config.xml'));
@@ -201,8 +203,8 @@ function resolveConfigFilePath(project_dir, platform, file) {
// XXX this checks for android studio projects
// only if none of the options above are satisfied does this get called
- if(platform === 'android' && !fs.existsSync(filepath)) {
- filepath = path.join(project_dir, 'app', 'src', 'main', 'res', 'xml', 'config.xml');
+ if (platform === 'android' && !fs.existsSync(filepath)) {
+ filepath = path.join(project_dir, 'app', 'src', 'main', 'res', 'xml', 'config.xml');
}
// None of the special cases matched, returning project_dir/file.
@@ -211,11 +213,11 @@ function resolveConfigFilePath(project_dir, platform, file) {
// Find out the real name of an iOS project
// TODO: glob is slow, need a better way or caching, or avoid using more than once.
-function getIOSProjectname(project_dir) {
+function getIOSProjectname (project_dir) {
var matches = modules.glob.sync(path.join(project_dir, '*.xcodeproj'));
var iospath;
if (matches.length === 1) {
- iospath = path.basename(matches[0],'.xcodeproj');
+ iospath = path.basename(matches[0], '.xcodeproj');
} else {
var msg;
if (matches.length === 0) {
@@ -229,7 +231,7 @@ function getIOSProjectname(project_dir) {
}
// determine if a plist file is binary
-function isBinaryPlist(filename) {
+function isBinaryPlist (filename) {
// I wish there was a synchronous way to read only the first 6 bytes of a
// file. This is wasteful :/
var buf = '' + fs.readFileSync(filename, 'utf8');
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/ConfigChanges/ConfigKeeper.js
----------------------------------------------------------------------
diff --git a/src/ConfigChanges/ConfigKeeper.js b/src/ConfigChanges/ConfigKeeper.js
index 894e922..0ef0435 100644
--- a/src/ConfigChanges/ConfigKeeper.js
+++ b/src/ConfigChanges/ConfigKeeper.js
@@ -28,18 +28,18 @@ var ConfigFile = require('./ConfigFile');
* project_dir/platform/file
* where file is the name used for the file in config munges.
******************************************************************************/
-function ConfigKeeper(project_dir, plugins_dir) {
+function ConfigKeeper (project_dir, plugins_dir) {
this.project_dir = project_dir;
this.plugins_dir = plugins_dir;
this._cached = {};
}
-ConfigKeeper.prototype.get = function ConfigKeeper_get(project_dir, platform, file) {
+ConfigKeeper.prototype.get = function ConfigKeeper_get (project_dir, platform, file) {
var self = this;
// This fixes a bug with older plugins - when specifying config xml instead of res/xml/config.xml
// https://issues.apache.org/jira/browse/CB-6414
- if(file == 'config.xml' && platform == 'android'){
+ if (file === 'config.xml' && platform === 'android') {
file = 'res/xml/config.xml';
}
var fake_path = path.join(project_dir, platform, file);
@@ -53,8 +53,7 @@ ConfigKeeper.prototype.get = function ConfigKeeper_get(project_dir, platform, fi
return config_file;
};
-
-ConfigKeeper.prototype.save_all = function ConfigKeeper_save_all() {
+ConfigKeeper.prototype.save_all = function ConfigKeeper_save_all () {
var self = this;
Object.keys(self._cached).forEach(function (fake_path) {
var config_file = self._cached[fake_path];
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[4/4] cordova-common git commit: CB-12895 : set up eslint and removed
jshint
Posted by au...@apache.org.
CB-12895 : set up eslint and removed jshint
Project: http://git-wip-us.apache.org/repos/asf/cordova-common/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-common/commit/54450166
Tree: http://git-wip-us.apache.org/repos/asf/cordova-common/tree/54450166
Diff: http://git-wip-us.apache.org/repos/asf/cordova-common/diff/54450166
Branch: refs/heads/master
Commit: 54450166db4c7facc785064ee5104cad5702faa8
Parents: 1cdc124
Author: Audrey So <au...@apache.org>
Authored: Fri Jun 9 11:02:48 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Fri Jul 14 15:28:48 2017 -0700
----------------------------------------------------------------------
.eslintignore | 1 +
.eslintrc.yml | 11 +
.jshintignore | 1 -
package.json | 12 +-
spec/.eslintrc.yml | 2 +
spec/.jshintrc | 11 -
spec/ActionStack.spec.js | 48 ++--
spec/ConfigChanges/ConfigChanges.spec.js | 190 ++++++++--------
spec/ConfigParser/ConfigParser.spec.js | 185 ++++++++--------
spec/CordovaCheck.spec.js | 40 ++--
spec/CordovaLogger.spec.js | 12 +-
spec/FileUpdater.spec.js | 134 ++++++------
spec/PlatformJson.spec.js | 42 ++--
spec/PluginInfo/PluginInfo.spec.js | 8 +-
spec/PluginInfo/PluginInfoProvider.spec.js | 4 +-
spec/PluginManager.spec.js | 66 +++---
spec/events.spec.js | 4 +-
spec/plist-helpers.spec.js | 15 +-
spec/superspawn.spec.js | 56 ++---
spec/util/xml-helpers.spec.js | 150 ++++++-------
src/.jshintrc | 10 -
src/ActionStack.js | 30 +--
src/ConfigChanges/ConfigChanges.js | 118 +++++-----
src/ConfigChanges/ConfigFile.js | 94 ++++----
src/ConfigChanges/ConfigKeeper.js | 9 +-
src/ConfigChanges/munge-util.js | 45 ++--
src/ConfigParser/ConfigParser.js | 219 +++++++++----------
src/CordovaCheck.js | 14 +-
src/CordovaError/CordovaError.js | 25 ++-
.../CordovaExternalToolErrorContext.js | 6 +-
src/CordovaLogger.js | 18 +-
src/FileUpdater.js | 141 ++++++------
src/PlatformJson.js | 65 +++---
src/PluginInfo/PluginInfo.js | 177 +++++++--------
src/PluginInfo/PluginInfoProvider.js | 14 +-
src/PluginManager.js | 91 ++++----
src/events.js | 3 +-
src/superspawn.js | 25 +--
src/util/addProperty.js | 4 +-
src/util/plist-helpers.js | 49 ++---
src/util/xml-helpers.js | 137 ++++++------
41 files changed, 1126 insertions(+), 1160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/.eslintignore
----------------------------------------------------------------------
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..161d0c6
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1 @@
+spec/fixtures/*
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..7701c82
--- /dev/null
+++ b/.eslintrc.yml
@@ -0,0 +1,11 @@
+root: true
+extends: semistandard
+rules:
+ indent:
+ - error
+ - 4
+ camelcase: off
+ padded-blocks: off
+ operator-linebreak: off
+ no-throw-literal: off
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/.jshintignore
----------------------------------------------------------------------
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index d606f61..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1 +0,0 @@
-spec/fixtures/*
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 44ccd3c..247c292 100644
--- a/package.json
+++ b/package.json
@@ -17,8 +17,8 @@
"node": ">=4.0.0"
},
"scripts": {
- "test": "npm run jshint && npm run jasmine",
- "jshint": "jshint src && jshint spec",
+ "test": "npm run eslint && npm run jasmine",
+ "eslint": "eslint src && eslint spec",
"jasmine": "jasmine JASMINE_CONFIG_PATH=spec/support/jasmine.json",
"cover": "istanbul cover --root src --print detail jasmine"
},
@@ -38,9 +38,15 @@
"unorm": "^1.3.3"
},
"devDependencies": {
+ "eslint": "^4.0.0",
+ "eslint-config-semistandard": "^11.0.0",
+ "eslint-config-standard": "^10.2.1",
+ "eslint-plugin-import": "^2.3.0",
+ "eslint-plugin-node": "^5.0.0",
+ "eslint-plugin-promise": "^3.5.0",
+ "eslint-plugin-standard": "^3.0.1",
"istanbul": "^0.4.5",
"jasmine": "^2.5.2",
- "jshint": "^2.8.0",
"promise-matchers": "^0.9.6",
"rewire": "^2.5.1"
},
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/spec/.eslintrc.yml b/spec/.eslintrc.yml
new file mode 100644
index 0000000..6afba65
--- /dev/null
+++ b/spec/.eslintrc.yml
@@ -0,0 +1,2 @@
+env:
+ jasmine: true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/.jshintrc
----------------------------------------------------------------------
diff --git a/spec/.jshintrc b/spec/.jshintrc
deleted file mode 100644
index 17eae32..0000000
--- a/spec/.jshintrc
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "node": true
- , "bitwise": true
- , "undef": true
- , "trailing": true
- , "quotmark": true
- , "indent": 4
- , "unused": "vars"
- , "latedef": "nofunc"
- , "jasmine": true
-}
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/ActionStack.spec.js
----------------------------------------------------------------------
diff --git a/spec/ActionStack.spec.js b/spec/ActionStack.spec.js
index 80d6c4d..44df820 100644
--- a/spec/ActionStack.spec.js
+++ b/spec/ActionStack.spec.js
@@ -20,58 +20,58 @@ var path = require('path');
var action_stack = require('../src/ActionStack');
var android_one_project = path.join(__dirname, '..', 'projects', 'android_one');
-describe('action-stack', function() {
+describe('action-stack', function () {
var stack;
- beforeEach(function() {
- stack = new action_stack();
+ beforeEach(function () {
+ stack = new action_stack(); /* eslint new-cap : 0 */
});
- describe('processing of actions', function() {
- it('Test 001 : should process actions one at a time until all are done', function() {
+ describe('processing of actions', function () {
+ it('Test 001 : should process actions one at a time until all are done', function () {
var first_spy = jasmine.createSpy();
var first_args = [1];
var second_spy = jasmine.createSpy();
var second_args = [2];
var third_spy = jasmine.createSpy();
var third_args = [3];
- stack.push(stack.createAction(first_spy, first_args, function(){}, []));
- stack.push(stack.createAction(second_spy, second_args, function(){}, []));
- stack.push(stack.createAction(third_spy, third_args, function(){}, []));
+ stack.push(stack.createAction(first_spy, first_args, function () {}, []));
+ stack.push(stack.createAction(second_spy, second_args, function () {}, []));
+ stack.push(stack.createAction(third_spy, third_args, function () {}, []));
stack.process('android', android_one_project);
expect(first_spy).toHaveBeenCalledWith(first_args[0]);
expect(second_spy).toHaveBeenCalledWith(second_args[0]);
expect(third_spy).toHaveBeenCalledWith(third_args[0]);
});
- it('Test 002 : should revert processed actions if an exception occurs', function(done) {
+ it('Test 002 : should revert processed actions if an exception occurs', function (done) {
spyOn(console, 'log');
var first_spy = jasmine.createSpy();
var first_args = [1];
var first_reverter = jasmine.createSpy();
var first_reverter_args = [true];
var process_err = new Error('process_err');
- var second_spy = jasmine.createSpy().and.callFake(function() {
+ var second_spy = jasmine.createSpy().and.callFake(function () {
throw process_err;
});
var second_args = [2];
var third_spy = jasmine.createSpy();
var third_args = [3];
stack.push(stack.createAction(first_spy, first_args, first_reverter, first_reverter_args));
- stack.push(stack.createAction(second_spy, second_args, function(){}, []));
- stack.push(stack.createAction(third_spy, third_args, function(){}, []));
+ stack.push(stack.createAction(second_spy, second_args, function () {}, []));
+ stack.push(stack.createAction(third_spy, third_args, function () {}, []));
// process should throw
var error;
stack.process('android', android_one_project)
- .then(function(){
- expect(false).toBe(true);
- }).fail(function(err){
- error = err;
- expect(error).toEqual(process_err);
- // first two actions should have been called, but not the third
- expect(first_spy).toHaveBeenCalledWith(first_args[0]);
- expect(second_spy).toHaveBeenCalledWith(second_args[0]);
- expect(third_spy).not.toHaveBeenCalledWith(third_args[0]);
- // first reverter should have been called after second action exploded
- expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]);
- }).fin(done);
+ .then(function () {
+ expect(false).toBe(true);
+ }).fail(function (err) {
+ error = err;
+ expect(error).toEqual(process_err);
+ // first two actions should have been called, but not the third
+ expect(first_spy).toHaveBeenCalledWith(first_args[0]);
+ expect(second_spy).toHaveBeenCalledWith(second_args[0]);
+ expect(third_spy).not.toHaveBeenCalledWith(third_args[0]);
+ // first reverter should have been called after second action exploded
+ expect(first_reverter).toHaveBeenCalledWith(first_reverter_args[0]);
+ }).fin(done);
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/ConfigChanges/ConfigChanges.spec.js
----------------------------------------------------------------------
diff --git a/spec/ConfigChanges/ConfigChanges.spec.js b/spec/ConfigChanges/ConfigChanges.spec.js
index 096a8ec..79e109a 100644
--- a/spec/ConfigChanges/ConfigChanges.spec.js
+++ b/spec/ConfigChanges/ConfigChanges.spec.js
@@ -17,29 +17,27 @@
under the License.
*/
-/* jshint sub:true */
-
-var configChanges = require('../../src/ConfigChanges/ConfigChanges'),
- xml_helpers = require('../../src/util/xml-helpers'),
- fs = require('fs'),
- os = require('osenv'),
- et = require('elementtree'),
- path = require('path'),
- shell = require('shelljs'),
- temp = path.join(os.tmpdir(), 'plugman'),
- dummyplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.dummyplugin'),
- cbplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.childbrowser'),
- childrenplugin = path.join(__dirname, '../fixtures/plugins/org.test.multiple-children'),
- shareddepsplugin = path.join(__dirname, '../fixtures/plugins/org.test.shareddeps'),
- configplugin = path.join(__dirname, '../fixtures/plugins/org.test.configtest'),
- editconfigplugin = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest'),
- editconfigplugin_two = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest_two'),
- varplugin = path.join(__dirname, '../fixtures/plugins/com.adobe.vars'),
- plistplugin = path.join(__dirname, '../fixtures/plugins/org.apache.plist'),
- android_two_project = path.join(__dirname, '../fixtures/projects/android_two/*'),
- android_two_no_perms_project = path.join(__dirname, '../fixtures/projects/android_two_no_perms', '*'),
- ios_config_xml = path.join(__dirname, '../fixtures/projects/ios-config-xml/*'),
- plugins_dir = path.join(temp, 'cordova', 'plugins');
+var configChanges = require('../../src/ConfigChanges/ConfigChanges');
+var xml_helpers = require('../../src/util/xml-helpers');
+var fs = require('fs');
+var os = require('osenv');
+var et = require('elementtree');
+var path = require('path');
+var shell = require('shelljs');
+var temp = path.join(os.tmpdir(), 'plugman');
+var dummyplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.dummyplugin');
+var cbplugin = path.join(__dirname, '../fixtures/plugins/org.test.plugins.childbrowser');
+var childrenplugin = path.join(__dirname, '../fixtures/plugins/org.test.multiple-children');
+var shareddepsplugin = path.join(__dirname, '../fixtures/plugins/org.test.shareddeps');
+var configplugin = path.join(__dirname, '../fixtures/plugins/org.test.configtest');
+var editconfigplugin = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest');
+var editconfigplugin_two = path.join(__dirname, '../fixtures/plugins/org.test.editconfigtest_two');
+var varplugin = path.join(__dirname, '../fixtures/plugins/com.adobe.vars');
+var plistplugin = path.join(__dirname, '../fixtures/plugins/org.apache.plist');
+var android_two_project = path.join(__dirname, '../fixtures/projects/android_two/*');
+var android_two_no_perms_project = path.join(__dirname, '../fixtures/projects/android_two_no_perms', '*');
+var ios_config_xml = path.join(__dirname, '../fixtures/projects/ios-config-xml/*');
+var plugins_dir = path.join(temp, 'cordova', 'plugins');
var mungeutil = require('../../src/ConfigChanges/munge-util');
var PlatformJson = require('../../src/PlatformJson');
var PluginInfoProvider = require('../../src/PluginInfo/PluginInfoProvider');
@@ -53,43 +51,43 @@ var cfg = new ConfigParser(xml);
var pluginInfoProvider = new PluginInfoProvider();
-function innerXML(xmltext) {
- return xmltext.replace(/^<[\w\s\-=\/"\.]+>/, '').replace(/<\/[\w\s\-=\/"\.]+>$/,'');
+function innerXML (xmltext) {
+ return xmltext.replace(/^<[\w\s\-=\/"\.]+>/, '').replace(/<\/[\w\s\-=\/"\.]+>$/, ''); /* eslint no-useless-escape : 0 */
}
-function get_munge_change(munge, keys) {
+function get_munge_change (munge, keys) {
return mungeutil.deep_find.apply(null, arguments);
}
-describe('config-changes module', function() {
- beforeEach(function() {
+describe('config-changes module', function () {
+ beforeEach(function () {
shell.mkdir('-p', temp);
shell.mkdir('-p', plugins_dir);
});
- afterEach(function() {
+ afterEach(function () {
shell.rm('-rf', temp);
});
- describe('queue methods', function() {
- describe('addInstalledPluginToPrepareQueue', function() {
- it('Test 001 : should append specified plugin to platform.json', function() {
+ describe('queue methods', function () {
+ describe('addInstalledPluginToPrepareQueue', function () {
+ it('Test 001 : should append specified plugin to platform.json', function () {
var platformJson = new PlatformJson(null, 'android', null);
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
var json = platformJson.root;
expect(json.prepare_queue.installed[0].plugin).toEqual('org.test.plugins.dummyplugin');
expect(json.prepare_queue.installed[0].vars).toEqual({});
});
- it('Test 002 : should append specified plugin with any variables to platform.json', function() {
+ it('Test 002 : should append specified plugin with any variables to platform.json', function () {
var platformJson = new PlatformJson(null, 'android', null);
- platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {'dude':'man'});
+ platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {'dude': 'man'});
var json = platformJson.root;
expect(json.prepare_queue.installed[0].plugin).toEqual('org.test.plugins.dummyplugin');
- expect(json.prepare_queue.installed[0].vars).toEqual({'dude':'man'});
+ expect(json.prepare_queue.installed[0].vars).toEqual({'dude': 'man'});
});
});
- describe('addUninstalledPluginToPrepareQueue', function() {
- it('Test 003 : should append specified plugin to platform.json', function() {
+ describe('addUninstalledPluginToPrepareQueue', function () {
+ it('Test 003 : should append specified plugin to platform.json', function () {
var platformJson = new PlatformJson(null, 'android', null);
platformJson.addUninstalledPluginToPrepareQueue('org.test.plugins.dummyplugin');
var json = platformJson.root;
@@ -98,15 +96,15 @@ describe('config-changes module', function() {
});
});
- describe('load method', function() {
- it('Test 004 : should return an empty config json object if file doesn\'t exist', function() {
+ describe('load method', function () {
+ it('Test 004 : should return an empty config json object if file doesn\'t exist', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
expect(platformJson.root).toBeDefined();
expect(platformJson.root.prepare_queue).toBeDefined();
expect(platformJson.root.config_munge).toBeDefined();
expect(platformJson.root.installed_plugins).toBeDefined();
});
- it('Test 005 : should return the json file if it exists', function() {
+ it('Test 005 : should return the json file if it exists', function () {
var filepath = path.join(plugins_dir, 'android.json');
var json = {
prepare_queue: {installed: [], uninstalled: []},
@@ -119,42 +117,42 @@ describe('config-changes module', function() {
});
});
- describe('save method', function() {
- it('Test 006 : should write out specified json', function() {
+ describe('save method', function () {
+ it('Test 006 : should write out specified json', function () {
var filepath = path.join(plugins_dir, 'android.json');
- var platformJson = new PlatformJson(filepath, 'android', {foo:true});
+ var platformJson = new PlatformJson(filepath, 'android', {foo: true});
platformJson.save();
expect(JSON.parse(fs.readFileSync(filepath, 'utf-8'))).toEqual(platformJson.root);
});
});
- describe('generate_plugin_config_munge method', function() {
- describe('for android projects', function() {
- beforeEach(function() {
+ describe('generate_plugin_config_munge method', function () {
+ describe('for android projects', function () {
+ beforeEach(function () {
shell.cp('-rf', android_two_project, temp);
});
- it('Test 007 : should return a flat config hierarchy for simple, one-off config changes', function() {
+ it('Test 007 : should return a flat config hierarchy for simple, one-off config changes', function () {
var xml;
var dummy_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(dummyplugin, 'plugin.xml'), 'utf-8')));
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(dummyplugin), {});
expect(munge.files['AndroidManifest.xml']).toBeDefined();
expect(munge.files['AndroidManifest.xml'].parents['/manifest/application']).toBeDefined();
- xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="AndroidManifest.xml"]'))).write({xml_declaration:false});
+ xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="AndroidManifest.xml"]'))).write({xml_declaration: false});
xml = innerXML(xml);
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest/application', xml).count).toEqual(1);
expect(munge.files['res/xml/plugins.xml']).toBeDefined();
expect(munge.files['res/xml/plugins.xml'].parents['/plugins']).toBeDefined();
- xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/plugins.xml"]'))).write({xml_declaration:false});
+ xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/plugins.xml"]'))).write({xml_declaration: false});
xml = innerXML(xml);
expect(get_munge_change(munge, 'res/xml/plugins.xml', '/plugins', xml).count).toEqual(1);
expect(munge.files['res/xml/config.xml']).toBeDefined();
expect(munge.files['res/xml/config.xml'].parents['/cordova/plugins']).toBeDefined();
- xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/config.xml"]'))).write({xml_declaration:false});
+ xml = (new et.ElementTree(dummy_xml.find('./platform[@name="android"]/config-file[@target="res/xml/config.xml"]'))).write({xml_declaration: false});
xml = innerXML(xml);
expect(get_munge_change(munge, 'res/xml/config.xml', '/cordova/plugins', xml).count).toEqual(1);
});
- it('Test 008 : should split out multiple children of config-file elements into individual leaves', function() {
+ it('Test 008 : should split out multiple children of config-file elements into individual leaves', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME: 'com.alunny.childapp'});
expect(munge.files['AndroidManifest.xml']).toBeDefined();
@@ -169,23 +167,23 @@ describe('config-changes module', function() {
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="com.alunny.childapp.permission.C2D_MESSAGE" />')).toBeDefined();
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />')).toBeDefined();
});
- it('Test 009 : should not use xml comments as config munge leaves', function() {
+ it('Test 009 : should not use xml comments as config munge leaves', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {});
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<!--library-->')).not.toBeDefined();
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<!-- GCM connects to Google Services. -->')).not.toBeDefined();
});
- it('Test 010 : should increment config hierarchy leaves if different config-file elements target the same file + selector + xml', function() {
+ it('Test 010 : should increment config hierarchy leaves if different config-file elements target the same file + selector + xml', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(configplugin), {});
expect(get_munge_change(munge, 'res/xml/config.xml', '/widget', '<poop />').count).toEqual(2);
});
- it('Test 011 : should take into account interpolation variables', function() {
+ it('Test 011 : should take into account interpolation variables', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
- var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME:'ca.filmaj.plugins'});
+ var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(childrenplugin), {PACKAGE_NAME: 'ca.filmaj.plugins'});
expect(get_munge_change(munge, 'AndroidManifest.xml', '/manifest', '<uses-permission android:name="ca.filmaj.plugins.permission.C2D_MESSAGE" />')).toBeDefined();
});
- it('Test 012 : should create munges for platform-agnostic config.xml changes', function() {
+ it('Test 012 : should create munges for platform-agnostic config.xml changes', function () {
var munger = new configChanges.PlatformMunger('android', temp, 'unused', null, pluginInfoProvider);
var munge = munger.generate_plugin_config_munge(pluginInfoProvider.get(dummyplugin), {});
expect(get_munge_change(munge, 'config.xml', '/*', '<access origin="build.phonegap.com" />')).toBeDefined();
@@ -194,27 +192,27 @@ describe('config-changes module', function() {
});
});
- describe('processing of plugins (via process method)', function() {
- beforeEach(function() {
+ describe('processing of plugins (via process method)', function () {
+ beforeEach(function () {
shell.cp('-rf', dummyplugin, plugins_dir);
});
- it('Test 014 : should generate config munges for queued plugins', function() {
+ it('Test 014 : should generate config munges for queued plugins', function () {
shell.cp('-rf', android_two_project, temp);
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.root.prepare_queue.installed = [{'plugin':'org.test.plugins.dummyplugin', 'vars':{}}];
+ platformJson.root.prepare_queue.installed = [{'plugin': 'org.test.plugins.dummyplugin', 'vars': {}}];
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
var spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({});
munger.process(plugins_dir);
expect(spy).toHaveBeenCalledWith(jasmine.any(PluginInfo), {});
});
- describe(': installation', function() {
- describe('of xml config files', function() {
- beforeEach(function() {
+ describe(': installation', function () {
+ describe('of xml config files', function () {
+ beforeEach(function () {
shell.cp('-rf', android_two_project, temp);
});
- it('Test 015 : should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function() {
+ it('Test 015 : should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.root.prepare_queue.installed = [{'plugin':'org.test.plugins.dummyplugin', 'vars':{}}];
+ platformJson.root.prepare_queue.installed = [{'plugin': 'org.test.plugins.dummyplugin', 'vars': {}}];
var spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true);
@@ -226,7 +224,7 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/application');
expect(spy.calls.argsFor(3)[2]).toEqual('/cordova/plugins');
});
- it('Test 016 : should not call graftXML for a config munge that already exists from another plugin', function() {
+ it('Test 016 : should not call graftXML for a config munge that already exists from another plugin', function () {
shell.cp('-rf', configplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.configtest', {});
@@ -236,7 +234,7 @@ describe('config-changes module', function() {
munger.process(plugins_dir);
expect(spy.calls.count()).toEqual(1);
});
- it('Test 017 : should not call graftXML for a config munge targeting a config file that does not exist', function() {
+ it('Test 017 : should not call graftXML for a config munge targeting a config file that does not exist', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', {});
@@ -246,7 +244,7 @@ describe('config-changes module', function() {
munger.process(plugins_dir);
expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
});
- it('Test 018 : should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function() {
+ it('Test 018 : should call graftXMLMerge for every new config munge with mode \'merge\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
@@ -258,7 +256,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']');
});
- it('Test 019 : should call graftXMLMerge with --force for every new config munge with mode \'merge\' it introduces', function() {
+ it('Test 019 : should call graftXMLMerge with --force for every new config munge with mode \'merge\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -274,7 +272,7 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(1)[2]).toEqual('/manifest/application/activity[@android:name=\'org.test.DroidGap\']');
expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/uses-sdk');
});
- it('Test 020 : should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function() {
+ it('Test 020 : should call graftXMLOverwrite for every new config munge with mode \'overwrite\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest', {});
@@ -286,7 +284,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity');
});
- it('Test 021 : should call graftXMLOverwrite with --force for every new config munge with mode \'overwrite\' it introduces', function() {
+ it('Test 021 : should call graftXMLOverwrite with --force for every new config munge with mode \'overwrite\' it introduces', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -301,7 +299,7 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/application/activity');
expect(spy.calls.argsFor(1)[2]).toEqual('/manifest/application/activity[@android:name=\'ChildApp\']');
});
- it('Test 022 : should not install plugin when there are edit-config conflicts', function() {
+ it('Test 022 : should not install plugin when there are edit-config conflicts', function () {
shell.cp('-rf', editconfigplugin, plugins_dir);
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -309,9 +307,9 @@ describe('config-changes module', function() {
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {});
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
- expect(function() {munger.process(plugins_dir);}).toThrow(new Error('There was a conflict trying to modify attributes with <edit-config> in plugin org.test.editconfigtest_two. The conflicting plugin, org.test.editconfigtest, already modified the same attributes. The conflict must be resolved before org.test.editconfigtest_two can be added. You may use --force to add the plugin and overwrite the conflicting attributes.'));
+ expect(function () { munger.process(plugins_dir); }).toThrow(new Error('There was a conflict trying to modify attributes with <edit-config> in plugin org.test.editconfigtest_two. The conflicting plugin, org.test.editconfigtest, already modified the same attributes. The conflict must be resolved before org.test.editconfigtest_two can be added. You may use --force to add the plugin and overwrite the conflicting attributes.'));
});
- it('should call graftXMLMerge for every new config.xml config munge with mode \'merge\' it introduces', function() {
+ it('should call graftXMLMerge for every new config.xml config munge with mode \'merge\' it introduces', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
var spy = spyOn(xml_helpers, 'graftXMLMerge').and.returnValue(true);
@@ -322,7 +320,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/uses-sdk');
});
- it('should call graftXMLOverwrite for every new config.xml config munge with mode \'overwrite\' it introduces', function() {
+ it('should call graftXMLOverwrite for every new config.xml config munge with mode \'overwrite\' it introduces', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
var spy = spyOn(xml_helpers, 'graftXMLOverwrite').and.returnValue(true);
@@ -333,7 +331,7 @@ describe('config-changes module', function() {
expect(spy.calls.count()).toEqual(1);
expect(spy.calls.argsFor(0)[2]).toEqual('/manifest/uses-sdk');
});
- it('should call pruneXMLRemove for every new config.xml config munge with mode \'remove\' it introduces', function() {
+ it('should call pruneXMLRemove for every new config.xml config munge with mode \'remove\' it introduces', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
// var spy = spyOn(xml_helpers, 'pruneXMLRemove').andReturn(true);
@@ -347,7 +345,7 @@ describe('config-changes module', function() {
expect(sdk).toBeDefined();
expect(sdk.attrib['android:maxSdkVersion']).toBeUndefined();
});
- it('should overwrite plugin config munge for every conflicting config.xml config munge', function() {
+ it('should overwrite plugin config munge for every conflicting config.xml config munge', function () {
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
@@ -361,7 +359,7 @@ describe('config-changes module', function() {
expect(sdk).toBeDefined();
expect(sdk.attrib['android:targetSdkVersion']).toEqual('24');
});
- it('should overwrite config.xml config munge for every new config.xml config munge that has the same target', function() {
+ it('should overwrite config.xml config munge for every new config.xml config munge that has the same target', function () {
var editconfig_cfg = new ConfigParser(editconfig_xml);
var platformJson = PlatformJson.load(plugins_dir, 'android');
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
@@ -376,27 +374,27 @@ describe('config-changes module', function() {
expect(sdk.attrib['android:minSdkVersion']).toEqual('5');
expect(sdk.attrib['android:maxSdkVersion']).toBeUndefined();
});
- it('should throw error for conflicting plugin config munge with config.xml config munge', function() {
+ it('should throw error for conflicting plugin config munge with config.xml config munge', function () {
shell.cp('-rf', editconfigplugin_two, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('org.test.editconfigtest_two', {}, true, true);
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.add_config_changes(cfg, true);
- expect(function() {munger.process(plugins_dir);}).toThrow(new Error('org.test.editconfigtest_two cannot be added. <edit-config> changes in this plugin conflicts with <edit-config> changes in config.xml. Conflicts must be resolved before plugin can be added.'));
+ expect(function () { munger.process(plugins_dir); }).toThrow(new Error('org.test.editconfigtest_two cannot be added. <edit-config> changes in this plugin conflicts with <edit-config> changes in config.xml. Conflicts must be resolved before plugin can be added.'));
});
});
- describe('of plist config files', function() {
- it('Test 023 : should write empty string nodes with no whitespace', function() {
+ describe('of plist config files', function () {
+ it('Test 023 : should write empty string nodes with no whitespace', function () {
shell.cp('-rf', ios_config_xml, temp);
shell.cp('-rf', varplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'ios');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {});
configChanges.process(plugins_dir, temp, 'ios', platformJson, pluginInfoProvider);
- expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>APluginNode<\/key>\n <string\/>/m);
+ expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>APluginNode<\/key>\n {4}<string\/>/m);
});
- it('Test 024 : should merge dictionaries and arrays, removing duplicates', function() {
+ it('Test 024 : should merge dictionaries and arrays, removing duplicates', function () {
shell.cp('-rf', ios_config_xml, temp);
shell.cp('-rf', plistplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'ios');
@@ -407,7 +405,7 @@ describe('config-changes module', function() {
expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).not.toMatch(/(<string>schema-a<\/string>[^]*){2,}/);
});
});
- it('Test 025 : should resolve wildcard config-file targets to the project, if applicable', function() {
+ it('Test 025 : should resolve wildcard config-file targets to the project, if applicable', function () {
shell.cp('-rf', ios_config_xml, temp);
shell.cp('-rf', cbplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'ios');
@@ -418,11 +416,11 @@ describe('config-changes module', function() {
munger.process(plugins_dir);
expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'SampleApp-Info.plist').replace(/\\/g, '/'), 'utf8');
});
- it('Test 026 : should move successfully installed plugins from queue to installed plugins section, and include/retain vars if applicable', function() {
+ it('Test 026 : should move successfully installed plugins from queue to installed plugins section, and include/retain vars if applicable', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', varplugin, plugins_dir);
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY':'hi'}, true);
+ platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY': 'hi'}, true);
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
@@ -433,8 +431,8 @@ describe('config-changes module', function() {
});
});
- describe(': uninstallation', function() {
- it('Test 027 : should call pruneXML for every config munge it completely removes from the app (every leaf that is decremented to 0)', function() {
+ describe(': uninstallation', function () {
+ it('Test 027 : should call pruneXML for every config munge it completely removes from the app (every leaf that is decremented to 0)', function () {
shell.cp('-rf', android_two_project, temp);
// Run through an "install"
@@ -453,12 +451,12 @@ describe('config-changes module', function() {
expect(spy.calls.argsFor(2)[2]).toEqual('/manifest/application');
expect(spy.calls.argsFor(3)[2]).toEqual('/cordova/plugins');
});
- it('Test 028 : should generate a config munge that interpolates variables into config changes, if applicable', function() {
+ it('Test 028 : should generate a config munge that interpolates variables into config changes, if applicable', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', varplugin, plugins_dir);
// Run through an "install"
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY':'canucks'});
+ platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY': 'canucks'});
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
@@ -471,7 +469,7 @@ describe('config-changes module', function() {
expect(munge_params[0].dir).toEqual(path.join(plugins_dir, 'com.adobe.vars'));
expect(munge_params[1]['API_KEY']).toEqual('canucks');
});
- it('Test 029 : should not call pruneXML for a config munge that another plugin depends on', function() {
+ it('Test 029 : should not call pruneXML for a config munge that another plugin depends on', function () {
shell.cp('-rf', android_two_no_perms_project, temp);
shell.cp('-rf', childrenplugin, plugins_dir);
shell.cp('-rf', shareddepsplugin, plugins_dir);
@@ -492,7 +490,7 @@ describe('config-changes module', function() {
expect(permission).toBeDefined();
expect(permission.attrib['android:name']).toEqual('android.permission.INTERNET');
});
- it('Test 030 : should not call pruneXML for a config munge targeting a config file that does not exist', function() {
+ it('Test 030 : should not call pruneXML for a config munge targeting a config file that does not exist', function () {
shell.cp('-rf', android_two_project, temp);
// install a plugin
var platformJson = PlatformJson.load(plugins_dir, 'android');
@@ -508,12 +506,12 @@ describe('config-changes module', function() {
expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
});
- it('Test 031 : should remove uninstalled plugins from installed plugins list', function() {
+ it('Test 031 : should remove uninstalled plugins from installed plugins list', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', varplugin, plugins_dir);
// install the var plugin
var platformJson = PlatformJson.load(plugins_dir, 'android');
- platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY':'eat my shorts'});
+ platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', {'API_KEY': 'eat my shorts'});
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
@@ -524,7 +522,7 @@ describe('config-changes module', function() {
expect(platformJson.root.prepare_queue.uninstalled.length).toEqual(0);
expect(platformJson.root.installed_plugins['com.adobe.vars']).not.toBeDefined();
});
- it('Test 032 : should call pruneXMLRestore for every config munge with mode \'merge\' or \'overwrite\' it removes from the app', function() {
+ it('Test 032 : should call pruneXMLRestore for every config munge with mode \'merge\' or \'overwrite\' it removes from the app', function () {
shell.cp('-rf', android_two_project, temp);
shell.cp('-rf', editconfigplugin, plugins_dir);
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/ConfigParser/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/spec/ConfigParser/ConfigParser.spec.js b/spec/ConfigParser/ConfigParser.spec.js
index 034f3d7..1075e83 100644
--- a/spec/ConfigParser/ConfigParser.spec.js
+++ b/spec/ConfigParser/ConfigParser.spec.js
@@ -16,19 +16,20 @@
specific language governing permissions and limitations
under the License.
*/
-var path = require('path'),
- fs = require('fs'),
- ConfigParser = require('../../src/ConfigParser/ConfigParser'),
- xml = path.join(__dirname, '../fixtures/test-config.xml'),
- xml_contents = fs.readFileSync(xml, 'utf-8');
+
+var path = require('path');
+var fs = require('fs');
+var ConfigParser = require('../../src/ConfigParser/ConfigParser');
+var xml = path.join(__dirname, '../fixtures/test-config.xml');
+var xml_contents = fs.readFileSync(xml, 'utf-8');
describe('config.xml parser', function () {
- var readFile;
- beforeEach(function() {
+ var readFile; /* eslint no-unused-vars : 0 */
+ beforeEach(function () {
readFile = spyOn(fs, 'readFileSync').and.returnValue(xml_contents);
});
- it('Test 001 : should create an instance based on an xml file', function() {
+ it('Test 001 : should create an instance based on an xml file', function () {
var cfg;
expect(function () {
cfg = new ConfigParser(xml);
@@ -37,59 +38,59 @@ describe('config.xml parser', function () {
expect(cfg.doc).toBeDefined();
});
- describe('methods', function() {
+ describe('methods', function () {
var cfg;
- beforeEach(function() {
+ beforeEach(function () {
cfg = new ConfigParser(xml);
});
- describe('package name / id', function() {
- it('Test 002 : should get the (default) packagename', function() {
+ describe('package name / id', function () {
+ it('Test 002 : should get the (default) packagename', function () {
expect(cfg.packageName()).toEqual('io.cordova.hellocordova');
});
- it('Test 003 : should allow setting the packagename', function() {
+ it('Test 003 : should allow setting the packagename', function () {
cfg.setPackageName('this.is.bat.country');
expect(cfg.packageName()).toEqual('this.is.bat.country');
});
});
- describe('package name / android-packageName', function() {
- it('Test 004 : should get the android packagename', function() {
+ describe('package name / android-packageName', function () {
+ it('Test 004 : should get the android packagename', function () {
expect(cfg.android_packageName()).toEqual('io.cordova.hellocordova.android');
});
});
- describe('package name / ios-CFBundleIdentifier', function() {
- it('Test 005 : should get the ios packagename', function() {
+ describe('package name / ios-CFBundleIdentifier', function () {
+ it('Test 005 : should get the ios packagename', function () {
expect(cfg.ios_CFBundleIdentifier()).toEqual('io.cordova.hellocordova.ios');
});
});
- describe('version', function() {
- it('Test 006 : should get the version', function() {
+ describe('version', function () {
+ it('Test 006 : should get the version', function () {
expect(cfg.version()).toEqual('0.0.1');
});
- it('Test 007 : should allow setting the version', function() {
+ it('Test 007 : should allow setting the version', function () {
cfg.setVersion('2.0.1');
expect(cfg.version()).toEqual('2.0.1');
});
});
- describe('app name', function() {
- it('Test 008 : should get the (default) app name', function() {
+ describe('app name', function () {
+ it('Test 008 : should get the (default) app name', function () {
expect(cfg.name()).toEqual('Hello Cordova');
});
- it('Test 009 : should allow setting the app name', function() {
+ it('Test 009 : should allow setting the app name', function () {
cfg.setName('this.is.bat.country');
expect(cfg.name()).toEqual('this.is.bat.country');
});
- describe('short name', function() {
- it('should default to the app name', function() {
+ describe('short name', function () {
+ it('should default to the app name', function () {
expect(cfg.shortName()).toEqual('Hello Cordova');
});
- it('should allow setting the app short name', function() {
+ it('should allow setting the app short name', function () {
cfg.setShortName('Hi CDV');
expect(cfg.name()).toEqual('Hello Cordova');
expect(cfg.shortName()).toEqual('Hi CDV');
@@ -97,73 +98,73 @@ describe('config.xml parser', function () {
});
});
- describe('preference', function() {
- it('Test 010 : should return the value of a global preference', function() {
+ describe('preference', function () {
+ it('Test 010 : should return the value of a global preference', function () {
expect(cfg.getPreference('fullscreen')).toEqual('true');
});
- it('Test 011 : should return the value of a platform-specific preference', function() {
+ it('Test 011 : should return the value of a platform-specific preference', function () {
expect(cfg.getPreference('android-minSdkVersion', 'android')).toEqual('10');
});
- it('Test 012 : should return an empty string for a non-existing preference', function() {
+ it('Test 012 : should return an empty string for a non-existing preference', function () {
expect(cfg.getPreference('zimzooo!')).toEqual('');
});
});
- describe('global preference', function() {
- it('Test 013 : should return the value of a global preference', function() {
+ describe('global preference', function () {
+ it('Test 013 : should return the value of a global preference', function () {
expect(cfg.getGlobalPreference('orientation')).toEqual('portrait');
});
- it('Test 014 : should return an empty string for a non-existing preference', function() {
+ it('Test 014 : should return an empty string for a non-existing preference', function () {
expect(cfg.getGlobalPreference('foobar')).toEqual('');
});
});
- describe('platform-specific preference', function() {
- it('Test 015 : should return the value of a platform specific preference', function() {
+ describe('platform-specific preference', function () {
+ it('Test 015 : should return the value of a platform specific preference', function () {
expect(cfg.getPlatformPreference('orientation', 'android')).toEqual('landscape');
});
- it('Test 016 : should return an empty string when querying for a non-existing preference', function() {
+ it('Test 016 : should return an empty string when querying for a non-existing preference', function () {
expect(cfg.getPlatformPreference('foobar', 'android')).toEqual('');
});
- it('Test 017 : should return an empty string when querying with unsupported platform', function() {
+ it('Test 017 : should return an empty string when querying with unsupported platform', function () {
expect(cfg.getPlatformPreference('orientation', 'foobar')).toEqual('');
});
});
- describe('plugin',function(){
- it('Test 018 : should read plugin id list', function() {
- var expectedList = [
- 'org.apache.cordova.pluginwithvars',
- 'org.apache.cordova.pluginwithurl',
- 'org.apache.cordova.pluginwithversion',
- 'org.apache.cordova.pluginwithurlandversion',
- 'org.apache.cordova.justaplugin',
- 'org.apache.cordova.legacyfeatureversion',
- 'org.apache.cordova.legacyfeatureurl',
- 'org.apache.cordova.legacyfeatureversionandurl'
- ];
- var list = cfg.getPluginIdList();
- expect(list.length).toEqual(expectedList.length);
- expectedList.forEach(function(plugin){
- expect(list).toContain(plugin);
- });
- });
- it('Test 019 : should read plugin given id', function(){
+ describe('plugin', function () {
+ it('Test 018 : should read plugin id list', function () {
+ var expectedList = [
+ 'org.apache.cordova.pluginwithvars',
+ 'org.apache.cordova.pluginwithurl',
+ 'org.apache.cordova.pluginwithversion',
+ 'org.apache.cordova.pluginwithurlandversion',
+ 'org.apache.cordova.justaplugin',
+ 'org.apache.cordova.legacyfeatureversion',
+ 'org.apache.cordova.legacyfeatureurl',
+ 'org.apache.cordova.legacyfeatureversionandurl'
+ ];
+ var list = cfg.getPluginIdList();
+ expect(list.length).toEqual(expectedList.length);
+ expectedList.forEach(function (plugin) {
+ expect(list).toContain(plugin);
+ });
+ });
+ it('Test 019 : should read plugin given id', function () {
var plugin = cfg.getPlugin('org.apache.cordova.justaplugin');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.justaplugin');
expect(plugin.variables).toBeDefined();
});
- it('Test 020 : should not read plugin given undefined id', function(){
+ it('Test 020 : should not read plugin given undefined id', function () {
var plugin = cfg.getPlugin('org.apache.cordova.undefinedplugin');
expect(plugin).not.toBeDefined();
});
- it('Test 021 : should read plugin with src and store it in spec field', function(){
+ it('Test 021 : should read plugin with src and store it in spec field', function () {
var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurl');
expect(plugin.spec).toEqual('http://cordova.apache.org/pluginwithurl');
});
- it('Test 022 : should read plugin with version and store it in spec field', function(){
+ it('Test 022 : should read plugin with version and store it in spec field', function () {
var plugin = cfg.getPlugin('org.apache.cordova.pluginwithversion');
expect(plugin.spec).toEqual('1.1.1');
});
- it('Test 023 : should read plugin with source and version and store source in spec field', function(){
+ it('Test 023 : should read plugin with source and version and store source in spec field', function () {
var plugin = cfg.getPlugin('org.apache.cordova.pluginwithurlandversion');
expect(plugin.spec).toEqual('http://cordova.apache.org/pluginwithurlandversion');
});
@@ -173,22 +174,22 @@ describe('config.xml parser', function () {
expect(plugin.variables.var).toBeDefined();
expect(plugin.variables.var).toEqual('varvalue');
});
- it('Test 025 : should allow adding a new plugin', function(){
- cfg.addPlugin({name:'myplugin'});
+ it('Test 025 : should allow adding a new plugin', function () {
+ cfg.addPlugin({name: 'myplugin'});
var plugins = cfg.doc.findall('plugin');
- var pluginNames = plugins.map(function(plugin){
+ var pluginNames = plugins.map(function (plugin) {
return plugin.attrib.name;
});
expect(pluginNames).toContain('myplugin');
});
- it('Test 026 : should allow adding features with params', function(){
- cfg.addPlugin({name:'aplugin'}, [{name:'paraname',value:'paravalue'}]);
+ it('Test 026 : should allow adding features with params', function () {
+ cfg.addPlugin({name: 'aplugin'}, [{name: 'paraname', value: 'paravalue'}]);
// Additional check for new parameters syntax
- cfg.addPlugin({name:'bplugin'}, {paraname: 'paravalue'});
+ cfg.addPlugin({name: 'bplugin'}, {paraname: 'paravalue'});
var plugins = cfg.doc.findall('plugin')
- .filter(function (plugin) {
- return plugin.attrib.name === 'aplugin' || plugin.attrib.name === 'bplugin';
- });
+ .filter(function (plugin) {
+ return plugin.attrib.name === 'aplugin' || plugin.attrib.name === 'bplugin';
+ });
expect(plugins.length).toBe(2);
plugins.forEach(function (plugin) {
var variables = plugin.findall('variable');
@@ -196,7 +197,7 @@ describe('config.xml parser', function () {
expect(variables[0].attrib.value).toEqual('paravalue');
});
});
- it('Test 027 : should be able to read legacy feature entries with a version', function(){
+ it('Test 027 : should be able to read legacy feature entries with a version', function () {
var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversion');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureversion');
@@ -204,87 +205,87 @@ describe('config.xml parser', function () {
expect(plugin.variables).toBeDefined();
expect(plugin.variables.aVar).toEqual('aValue');
});
- it('Test 028 : should be able to read legacy feature entries with a url', function(){
+ it('Test 028 : should be able to read legacy feature entries with a url', function () {
var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureurl');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureurl');
expect(plugin.spec).toEqual('http://cordova.apache.org/legacyfeatureurl');
});
- it('Test 029 : should be able to read legacy feature entries with a version and a url', function(){
+ it('Test 029 : should be able to read legacy feature entries with a version and a url', function () {
var plugin = cfg.getPlugin('org.apache.cordova.legacyfeatureversionandurl');
expect(plugin).toBeDefined();
expect(plugin.name).toEqual('org.apache.cordova.legacyfeatureversionandurl');
expect(plugin.spec).toEqual('http://cordova.apache.org/legacyfeatureversionandurl');
});
- it('Test 030 : it should remove given plugin', function(){
+ it('Test 030 : it should remove given plugin', function () {
cfg.removePlugin('org.apache.cordova.justaplugin');
var plugins = cfg.doc.findall('plugin');
- var pluginNames = plugins.map(function(plugin){
+ var pluginNames = plugins.map(function (plugin) {
return plugin.attrib.name;
});
expect(pluginNames).not.toContain('org.apache.cordova.justaplugin');
});
- it('Test 031 : it should remove given legacy feature id', function(){
+ it('Test 031 : it should remove given legacy feature id', function () {
cfg.removePlugin('org.apache.cordova.legacyplugin');
var plugins = cfg.doc.findall('feature');
- var pluginNames = plugins.map(function(plugin){
+ var pluginNames = plugins.map(function (plugin) {
return plugin.attrib.name;
});
expect(pluginNames).not.toContain('org.apache.cordova.legacyplugin');
});
- it('Test 032 : it should read <access> tag entries', function(){
+ it('Test 032 : it should read <access> tag entries', function () {
var accesses = cfg.getAccesses();
expect(accesses.length).not.toEqual(0);
});
- it('Test 033 : it should read <allow-navigation> tag entries', function(){
+ it('Test 033 : it should read <allow-navigation> tag entries', function () {
var navigations = cfg.getAllowNavigations();
expect(navigations.length).not.toEqual(0);
});
- it('Test 034 : it should read <allow-intent> tag entries', function(){
+ it('Test 034 : it should read <allow-intent> tag entries', function () {
var intents = cfg.getAllowIntents();
expect(intents.length).not.toEqual(0);
});
- it('it should read <edit-config> tag entries', function(){
+ it('it should read <edit-config> tag entries', function () {
var editConfigs = cfg.getEditConfigs('android');
expect(editConfigs.length).not.toEqual(0);
});
});
- describe('static resources', function() {
+ describe('static resources', function () {
var hasPlatformPropertyDefined = function (e) { return !!e.platform; };
var hasSrcPropertyDefined = function (e) { return !!e.src; };
var hasTargetPropertyDefined = function (e) { return !!e.target; };
var hasDensityPropertyDefined = function (e) { return !!e.density; };
var hasPlatformPropertyUndefined = function (e) { return !e.platform; };
- it('Test 035 : should fetch shared resources if platform parameter is not specified', function() {
+ it('Test 035 : should fetch shared resources if platform parameter is not specified', function () {
expect(cfg.getStaticResources(null, 'icon').length).toBe(2);
expect(cfg.getStaticResources(null, 'icon').every(hasPlatformPropertyUndefined)).toBeTruthy();
});
- it('Test 036 : should fetch platform-specific resources along with shared if platform parameter is specified', function() {
+ it('Test 036 : should fetch platform-specific resources along with shared if platform parameter is specified', function () {
expect(cfg.getStaticResources('android', 'icon').length).toBe(5);
expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).length).toBe(3);
expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyUndefined)).toBeTruthy();
});
- it('Test 037 : should parse resources\' attributes', function() {
+ it('Test 037 : should parse resources\' attributes', function () {
expect(cfg.getStaticResources(null, 'icon').every(hasSrcPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('windows', 'icon').filter(hasPlatformPropertyDefined).every(hasTargetPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy();
expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy();
});
- it('Test 038 : should have defaultResource property', function() {
+ it('Test 038 : should have defaultResource property', function () {
expect(cfg.getStaticResources(null, 'icon').defaultResource).toBeDefined();
expect(cfg.getStaticResources(null, 'icon').defaultResource.src).toBe('icon.png');
});
- it('Test 039 : should have getDefault method returning defaultResource property', function() {
+ it('Test 039 : should have getDefault method returning defaultResource property', function () {
expect(cfg.getStaticResources(null, 'icon').defaultResource).toEqual(cfg.getStaticResources(null, 'icon').getDefault());
});
- it('Test 040 : should have getBySize method returning resource with size specified or null', function() {
+ it('Test 040 : should have getBySize method returning resource with size specified or null', function () {
expect(cfg.getStaticResources('windows', 'icon').getBySize(128)).toBe(null);
expect(cfg.getStaticResources('windows', 'icon').getBySize(72)).toBeDefined();
expect(cfg.getStaticResources('windows', 'icon').getBySize(72).width).toBe(72);
@@ -292,29 +293,29 @@ describe('config.xml parser', function () {
expect(cfg.getStaticResources('windows', 'icon').getBySize(null, 48).height).toBe(48);
});
- it('Test 041 : should have getByDensity method returning resource with density specified or null', function() {
+ it('Test 041 : should have getByDensity method returning resource with density specified or null', function () {
expect(cfg.getStaticResources('android', 'icon').getByDensity('hdpi')).toBe(null);
expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi')).toBeDefined();
expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi').src).toBe('logo-android.png');
});
});
- describe('file resources', function() {
+ describe('file resources', function () {
var hasSrcPropertyDefined = function (e) { return !!e.src; };
var hasTargetPropertyDefined = function (e) { return !!e.target; };
var hasArchPropertyDefined = function (e) { return !!e.arch; };
- it('should fetch platform-specific resources', function() {
+ it('should fetch platform-specific resources', function () {
expect(cfg.getFileResources('android').length).toBe(2);
});
- it('should parse resources\' attributes', function() {
+ it('should parse resources\' attributes', function () {
expect(cfg.getFileResources('android').every(hasSrcPropertyDefined)).toBeTruthy();
expect(cfg.getFileResources('android').every(hasTargetPropertyDefined)).toBeTruthy();
expect(cfg.getFileResources('windows').every(hasArchPropertyDefined)).toBeTruthy();
});
- it('should find resources at the top level', function() {
+ it('should find resources at the top level', function () {
expect(cfg.getFileResources('android', true).length).toBe(3);
});
});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/CordovaCheck.spec.js
----------------------------------------------------------------------
diff --git a/spec/CordovaCheck.spec.js b/spec/CordovaCheck.spec.js
index 8745a40..5a2fdc0 100644
--- a/spec/CordovaCheck.spec.js
+++ b/spec/CordovaCheck.spec.js
@@ -17,43 +17,43 @@
under the License.
*/
-var shell = require('shelljs'),
- path = require('path'),
- CordovaCheck = require('../src/CordovaCheck');
+var shell = require('shelljs');
+var path = require('path');
+var CordovaCheck = require('../src/CordovaCheck');
var cwd = process.cwd();
-var home = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
+var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
var origPWD = process.env.PWD;
-describe('findProjectRoot method', function() {
- afterEach(function() {
+describe('findProjectRoot method', function () {
+ afterEach(function () {
process.env.PWD = origPWD;
process.chdir(cwd);
});
- function removeDir(someDirectory) {
+ function removeDir (someDirectory) {
shell.rm('-rf', someDirectory);
}
- it('Test 001 : should return false if it hits the home directory', function() {
+ it('Test 001 : should return false if it hits the home directory', function () {
var somedir = path.join(home, 'somedir');
removeDir(somedir);
shell.mkdir(somedir);
expect(CordovaCheck.findProjectRoot(somedir)).toEqual(false);
});
- it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function() {
+ it('Test 002 : should return false if it cannot find a .cordova directory up the directory tree', function () {
var somedir = path.join(home, '..');
expect(CordovaCheck.findProjectRoot(somedir)).toEqual(false);
});
- it('Test 003 : should return the first directory it finds with a .cordova folder in it', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 003 : should return the first directory it finds with a .cordova folder in it', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
shell.mkdir('-p', path.join(somedir, 'www', 'config.xml'));
expect(CordovaCheck.findProjectRoot(somedir)).toEqual(somedir);
});
- it('Test 004 : should ignore PWD when its undefined', function() {
+ it('Test 004 : should ignore PWD when its undefined', function () {
delete process.env.PWD;
- var somedir = path.join(home,'somedir');
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -62,8 +62,8 @@ describe('findProjectRoot method', function() {
process.chdir(anotherdir);
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
- it('Test 005 : should use PWD when available', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 005 : should use PWD when available', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -72,8 +72,8 @@ describe('findProjectRoot method', function() {
process.chdir(path.sep);
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
- it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 006 : should use cwd as a fallback when PWD is not a cordova dir', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -82,8 +82,8 @@ describe('findProjectRoot method', function() {
process.chdir(anotherdir);
expect(CordovaCheck.findProjectRoot()).toEqual(somedir);
});
- it('Test 007 : should ignore platform www/config.xml', function() {
- var somedir = path.join(home,'somedir');
+ it('Test 007 : should ignore platform www/config.xml', function () {
+ var somedir = path.join(home, 'somedir');
var anotherdir = path.join(somedir, 'anotherdir');
removeDir(somedir);
shell.mkdir('-p', anotherdir);
@@ -92,4 +92,4 @@ describe('findProjectRoot method', function() {
shell.mkdir('-p', path.join(somedir, 'config.xml'));
expect(CordovaCheck.findProjectRoot(anotherdir)).toEqual(somedir);
});
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/spec/CordovaLogger.spec.js
----------------------------------------------------------------------
diff --git a/spec/CordovaLogger.spec.js b/spec/CordovaLogger.spec.js
index fb46e73..388dad9 100644
--- a/spec/CordovaLogger.spec.js
+++ b/spec/CordovaLogger.spec.js
@@ -23,7 +23,7 @@ var EventEmitter = require('events').EventEmitter;
var DEFAULT_LEVELS = ['verbose', 'normal', 'warn', 'info', 'error', 'results'];
-describe('CordovaLogger class', function() {
+describe('CordovaLogger class', function () {
it('Test 001 : should be constructable', function () {
expect(new CordovaLogger()).toEqual(jasmine.any(CordovaLogger));
});
@@ -99,10 +99,10 @@ describe('CordovaLogger class', function() {
};
var listenerSpy = jasmine.createSpy('listenerSpy')
- .and.callFake(function (eventName) {
- eventName = eventNamesExclusions[eventName] || eventName;
- expect(logger.levels[eventName]).toBeDefined();
- });
+ .and.callFake(function (eventName) {
+ eventName = eventNamesExclusions[eventName] || eventName;
+ expect(logger.levels[eventName]).toBeDefined();
+ });
var emitter = new EventEmitter().on('newListener', listenerSpy);
logger.subscribe(emitter);
@@ -163,7 +163,7 @@ describe('CordovaLogger class', function() {
describe('adjustLevel method', function () {
it('Test 014 : should properly adjust log level', function () {
- var resetLogLevel = function() {
+ var resetLogLevel = function () {
logger.setLevel('normal');
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/4] cordova-common git commit: CB-12895 : set up eslint and removed
jshint
Posted by au...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/ConfigChanges/munge-util.js
----------------------------------------------------------------------
diff --git a/src/ConfigChanges/munge-util.js b/src/ConfigChanges/munge-util.js
index 0149bab..62648d8 100644
--- a/src/ConfigChanges/munge-util.js
+++ b/src/ConfigChanges/munge-util.js
@@ -19,14 +19,14 @@ var _ = require('underscore');
// add the count of [key1][key2]...[keyN] to obj
// return true if it didn't exist before
-exports.deep_add = function deep_add(obj, keys /* or key1, key2 .... */ ) {
- if ( !Array.isArray(keys) ) {
+exports.deep_add = function deep_add (obj, keys /* or key1, key2 .... */) {
+ if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
- return exports.process_munge(obj, true/*createParents*/, function (parentArray, k) {
- var found = _.find(parentArray, function(element) {
- return element.xml == k.xml;
+ return exports.process_munge(obj, true/* createParents */, function (parentArray, k) {
+ var found = _.find(parentArray, function (element) {
+ return element.xml === k.xml;
});
if (found) {
found.after = found.after || k.after;
@@ -40,16 +40,16 @@ exports.deep_add = function deep_add(obj, keys /* or key1, key2 .... */ ) {
// decrement the count of [key1][key2]...[keyN] from obj and remove if it reaches 0
// return true if it was removed or not found
-exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ ) {
- if ( !Array.isArray(keys) ) {
+exports.deep_remove = function deep_remove (obj, keys /* or key1, key2 .... */) {
+ if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
- var result = exports.process_munge(obj, false/*createParents*/, function (parentArray, k) {
+ var result = exports.process_munge(obj, false/* createParents */, function (parentArray, k) {
var index = -1;
var found = _.find(parentArray, function (element) {
index++;
- return element.xml == k.xml;
+ return element.xml === k.xml;
});
if (found) {
if (parentArray[index].oldAttrib) {
@@ -58,8 +58,7 @@ exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ )
found.count -= k.count;
if (found.count > 0) {
return false;
- }
- else {
+ } else {
parentArray.splice(index, 1);
}
}
@@ -71,14 +70,14 @@ exports.deep_remove = function deep_remove(obj, keys /* or key1, key2 .... */ )
// search for [key1][key2]...[keyN]
// return the object or undefined if not found
-exports.deep_find = function deep_find(obj, keys /* or key1, key2 .... */ ) {
- if ( !Array.isArray(keys) ) {
+exports.deep_find = function deep_find (obj, keys /* or key1, key2 .... */) {
+ if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
- return exports.process_munge(obj, false/*createParents?*/, function (parentArray, k) {
+ return exports.process_munge(obj, false/* createParents? */, function (parentArray, k) {
return _.find(parentArray, function (element) {
- return element.xml == (k.xml || k);
+ return element.xml === (k.xml || k);
});
}, keys);
};
@@ -87,20 +86,20 @@ exports.deep_find = function deep_find(obj, keys /* or key1, key2 .... */ ) {
// When createParents is true, add the file and parent items they are missing
// When createParents is false, stop and return undefined if the file and/or parent items are missing
-exports.process_munge = function process_munge(obj, createParents, func, keys /* or key1, key2 .... */ ) {
- if ( !Array.isArray(keys) ) {
+exports.process_munge = function process_munge (obj, createParents, func, keys /* or key1, key2 .... */) {
+ if (!Array.isArray(keys)) {
keys = Array.prototype.slice.call(arguments, 1);
}
var k = keys[0];
- if (keys.length == 1) {
+ if (keys.length === 1) {
return func(obj, k);
- } else if (keys.length == 2) {
+ } else if (keys.length === 2) {
if (!obj.parents[k] && !createParents) {
return undefined;
}
obj.parents[k] = obj.parents[k] || [];
return exports.process_munge(obj.parents[k], createParents, func, keys.slice(1));
- } else if (keys.length == 3){
+ } else if (keys.length === 3) {
if (!obj.files[k] && !createParents) {
return undefined;
}
@@ -115,7 +114,7 @@ exports.process_munge = function process_munge(obj, createParents, func, keys /*
// base[file][selector][child] += munge[file][selector][child]
// Returns a munge object containing values that exist in munge
// but not in base.
-exports.increment_munge = function increment_munge(base, munge) {
+exports.increment_munge = function increment_munge (base, munge) {
var diff = { files: {} };
for (var file in munge.files) {
@@ -138,7 +137,7 @@ exports.increment_munge = function increment_munge(base, munge) {
// base[file][selector][child] -= munge[file][selector][child]
// nodes that reached zero value are removed from base and added to the returned munge
// object.
-exports.decrement_munge = function decrement_munge(base, munge) {
+exports.decrement_munge = function decrement_munge (base, munge) {
var zeroed = { files: {} };
for (var file in munge.files) {
@@ -158,6 +157,6 @@ exports.decrement_munge = function decrement_munge(base, munge) {
};
// For better readability where used
-exports.clone_munge = function clone_munge(munge) {
+exports.clone_munge = function clone_munge (munge) {
return exports.increment_munge({}, munge);
};
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/ConfigParser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/src/ConfigParser/ConfigParser.js b/src/ConfigParser/ConfigParser.js
index 0b02b4c..ebaa2a3 100644
--- a/src/ConfigParser/ConfigParser.js
+++ b/src/ConfigParser/ConfigParser.js
@@ -17,24 +17,21 @@
under the License.
*/
-/* jshint sub:true */
-
-var et = require('elementtree'),
- xml= require('../util/xml-helpers'),
- CordovaError = require('../CordovaError/CordovaError'),
- fs = require('fs'),
- events = require('../events');
-
+var et = require('elementtree');
+var xml = require('../util/xml-helpers');
+var CordovaError = require('../CordovaError/CordovaError');
+var fs = require('fs');
+var events = require('../events');
/** Wraps a config.xml file */
-function ConfigParser(path) {
+function ConfigParser (path) {
this.path = path;
try {
this.doc = xml.parseElementtreeSync(path);
this.cdvNamespacePrefix = getCordovaNamespacePrefix(this.doc);
et.register_namespace(this.cdvNamespacePrefix, 'http://cordova.apache.org/ns/1.0');
} catch (e) {
- console.error('Parsing '+path+' failed');
+ console.error('Parsing ' + path + ' failed');
throw e;
}
var r = this.doc.getroot();
@@ -43,11 +40,11 @@ function ConfigParser(path) {
}
}
-function getNodeTextSafe(el) {
+function getNodeTextSafe (el) {
return el && el.text && el.text.trim();
}
-function findOrCreate(doc, name) {
+function findOrCreate (doc, name) {
var ret = doc.find(name);
if (!ret) {
ret = new et.Element(name);
@@ -56,12 +53,12 @@ function findOrCreate(doc, name) {
return ret;
}
-function getCordovaNamespacePrefix(doc){
+function getCordovaNamespacePrefix (doc) {
var rootAtribs = Object.getOwnPropertyNames(doc.getroot().attrib);
var prefix = 'cdv';
- for (var j = 0; j < rootAtribs.length; j++ ) {
- if(rootAtribs[j].indexOf('xmlns:') === 0 &&
- doc.getroot().attrib[rootAtribs[j]] === 'http://cordova.apache.org/ns/1.0'){
+ for (var j = 0; j < rootAtribs.length; j++) {
+ 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];
break;
@@ -76,7 +73,7 @@ function getCordovaNamespacePrefix(doc){
* @param {Array} elems An array of ElementTree nodes
* @return {String}
*/
-function findElementAttributeValue(attributeName, elems) {
+function findElementAttributeValue (attributeName, elems) {
elems = Array.isArray(elems) ? elems : [ elems ];
@@ -86,69 +83,69 @@ function findElementAttributeValue(attributeName, elems) {
return filteredElems.attrib.value;
}).pop();
- return value ? value : '';
+ return value || '';
}
ConfigParser.prototype = {
- getAttribute: function(attr) {
+ getAttribute: function (attr) {
return this.doc.getroot().attrib[attr];
},
- packageName: function(id) {
+ packageName: function (id) {
return this.getAttribute('id');
},
- setPackageName: function(id) {
+ setPackageName: function (id) {
this.doc.getroot().attrib['id'] = id;
},
- android_packageName: function() {
+ android_packageName: function () {
return this.getAttribute('android-packageName');
},
- android_activityName: function() {
+ android_activityName: function () {
return this.getAttribute('android-activityName');
},
- ios_CFBundleIdentifier: function() {
+ ios_CFBundleIdentifier: function () {
return this.getAttribute('ios-CFBundleIdentifier');
},
- name: function() {
+ name: function () {
return getNodeTextSafe(this.doc.find('name'));
},
- setName: function(name) {
+ setName: function (name) {
var el = findOrCreate(this.doc, 'name');
el.text = name;
},
- shortName: function() {
+ shortName: function () {
return this.doc.find('name').attrib['short'] || this.name();
},
- setShortName: function(shortname) {
+ setShortName: function (shortname) {
var el = findOrCreate(this.doc, 'name');
if (!el.text) {
el.text = shortname;
}
el.attrib['short'] = shortname;
},
- description: function() {
+ description: function () {
return getNodeTextSafe(this.doc.find('description'));
},
- setDescription: function(text) {
+ setDescription: function (text) {
var el = findOrCreate(this.doc, 'description');
el.text = text;
},
- version: function() {
+ version: function () {
return this.getAttribute('version');
},
- windows_packageVersion: function() {
+ windows_packageVersion: function () {
return this.getAttribute('windows-packageVersion');
},
- android_versionCode: function() {
+ android_versionCode: function () {
return this.getAttribute('android-versionCode');
},
- ios_CFBundleVersion: function() {
+ ios_CFBundleVersion: function () {
return this.getAttribute('ios-CFBundleVersion');
},
- setVersion: function(value) {
+ setVersion: function (value) {
this.doc.getroot().attrib['version'] = value;
},
- author: function() {
+ author: function () {
return getNodeTextSafe(this.doc.find('author'));
},
getGlobalPreference: function (name) {
@@ -166,7 +163,7 @@ ConfigParser.prototype = {
getPlatformPreference: function (name, platform) {
return findElementAttributeValue(name, this.doc.findall('platform[@name=\'' + platform + '\']/preference'));
},
- getPreference: function(name, platform) {
+ getPreference: function (name, platform) {
var platformPreference = '';
@@ -174,7 +171,7 @@ ConfigParser.prototype = {
platformPreference = this.getPlatformPreference(name, platform);
}
- return platformPreference ? platformPreference : this.getGlobalPreference(name);
+ return platformPreference || this.getGlobalPreference(name);
},
/**
@@ -184,11 +181,11 @@ ConfigParser.prototype = {
* "icon" and "splash" currently supported.
* @return {Array} Resources for the platform specified.
*/
- getStaticResources: function(platform, resourceName) {
- var ret = [],
- staticResources = [];
+ getStaticResources: function (platform, resourceName) {
+ var ret = [];
+ var staticResources = [];
if (platform) { // platform specific icons
- this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function(elt){
+ this.doc.findall('platform[@name=\'' + platform + '\']/' + resourceName).forEach(function (elt) {
elt.platform = platform; // mark as platform specific resource
staticResources.push(elt);
});
@@ -201,7 +198,7 @@ ConfigParser.prototype = {
var res = {};
res.src = elt.attrib.src;
res.target = elt.attrib.target || undefined;
- res.density = elt.attrib['density'] || elt.attrib[that.cdvNamespacePrefix+':density'] || elt.attrib['gap:density'];
+ res.density = elt.attrib['density'] || elt.attrib[that.cdvNamespacePrefix + ':density'] || elt.attrib['gap:density'];
res.platform = elt.platform || null; // null means icon represents default icon (shared between platforms)
res.width = +elt.attrib.width || undefined;
res.height = +elt.attrib.height || undefined;
@@ -219,13 +216,13 @@ ConfigParser.prototype = {
* @param {number} height Height of resource.
* @return {Resource} Resource object or null if not found.
*/
- ret.getBySize = function(width, height) {
- return ret.filter(function(res) {
+ ret.getBySize = function (width, height) {
+ return ret.filter(function (res) {
if (!res.width && !res.height) {
return false;
}
- return ((!res.width || (width == res.width)) &&
- (!res.height || (height == res.height)));
+ return ((!res.width || (width === res.width)) &&
+ (!res.height || (height === res.height)));
})[0] || null;
};
@@ -234,14 +231,14 @@ ConfigParser.prototype = {
* @param {string} density Density of resource.
* @return {Resource} Resource object or null if not found.
*/
- ret.getByDensity = function(density) {
- return ret.filter(function(res) {
- return res.density == density;
+ ret.getByDensity = function (density) {
+ return ret.filter(function (res) {
+ return res.density === density;
})[0] || null;
};
/** Returns default icons */
- ret.getDefault = function() {
+ ret.getDefault = function () {
return ret.defaultResource;
};
@@ -253,7 +250,7 @@ ConfigParser.prototype = {
* @param {string} platform Platform name
* @return {Resource[]} Array of icon objects.
*/
- getIcons: function(platform) {
+ getIcons: function (platform) {
return this.getStaticResources(platform, 'icon');
},
@@ -262,7 +259,7 @@ ConfigParser.prototype = {
* @param {string} platform Platform name
* @return {Resource[]} Array of Splash objects.
*/
- getSplashScreens: function(platform) {
+ getSplashScreens: function (platform) {
return this.getStaticResources(platform, 'splash');
},
@@ -273,11 +270,11 @@ ConfigParser.prototype = {
* root level.
* @return {Resource[]} Array of resource file objects.
*/
- getFileResources: function(platform, includeGlobal) {
+ getFileResources: function (platform, includeGlobal) {
var fileResources = [];
if (platform) { // platform specific resources
- fileResources = this.doc.findall('platform[@name=\'' + platform + '\']/resource-file').map(function(tag) {
+ fileResources = this.doc.findall('platform[@name=\'' + platform + '\']/resource-file').map(function (tag) {
return {
platform: platform,
src: tag.attrib.src,
@@ -290,7 +287,7 @@ ConfigParser.prototype = {
}
if (includeGlobal) {
- this.doc.findall('resource-file').forEach(function(tag) {
+ this.doc.findall('resource-file').forEach(function (tag) {
fileResources.push({
platform: platform || null,
src: tag.attrib.src,
@@ -311,23 +308,23 @@ ConfigParser.prototype = {
* @param {Array} platforms Platforms to look for scripts into (root scripts will be included as well).
* @return {Array} Script elements.
*/
- getHookScripts: function(hook, platforms) {
+ getHookScripts: function (hook, platforms) {
var self = this;
var scriptElements = self.doc.findall('./hook');
- if(platforms) {
+ if (platforms) {
platforms.forEach(function (platform) {
scriptElements = scriptElements.concat(self.doc.findall('./platform[@name="' + platform + '"]/hook'));
});
}
- function filterScriptByHookType(el) {
+ function filterScriptByHookType (el) {
return el.attrib.src && el.attrib.type && el.attrib.type.toLowerCase() === hook;
}
return scriptElements.filter(filterScriptByHookType);
},
- /**
+ /**
* Returns a list of plugin (IDs).
*
* This function also returns any plugin's that
@@ -336,13 +333,13 @@ ConfigParser.prototype = {
*/
getPluginIdList: function () {
var plugins = this.doc.findall('plugin');
- var result = plugins.map(function(plugin){
+ var result = plugins.map(function (plugin) {
return plugin.attrib.name;
});
var features = this.doc.findall('feature');
- features.forEach(function(element ){
+ features.forEach(function (element) {
var idTag = element.find('./param[@name="id"]');
- if(idTag){
+ if (idTag) {
result.push(idTag.attrib.value);
}
});
@@ -371,9 +368,9 @@ ConfigParser.prototype = {
// support arbitrary object as variables source
if (variables && typeof variables === 'object' && !Array.isArray(variables)) {
variables = Object.keys(variables)
- .map(function (variableName) {
- return {name: variableName, value: variables[variableName]};
- });
+ .map(function (variableName) {
+ return {name: variableName, value: variables[variableName]};
+ });
}
if (variables) {
@@ -393,15 +390,15 @@ ConfigParser.prototype = {
* @param {String} id
* @returns {object} plugin including any variables
*/
- getPlugin: function(id){
- if(!id){
+ getPlugin: function (id) {
+ if (!id) {
return undefined;
}
var pluginElement = this.doc.find('./plugin/[@name="' + id + '"]');
- if (null === pluginElement) {
- var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
- if(legacyFeature){
- events.emit('log', 'Found deprecated feature entry for ' + id +' in config.xml.');
+ if (pluginElement === null) {
+ var legacyFeature = this.doc.find('./feature/param[@name="id"][@value="' + id + '"]/..');
+ if (legacyFeature) {
+ events.emit('log', 'Found deprecated feature entry for ' + id + ' in config.xml.');
return featureToPlugin(legacyFeature);
}
return undefined;
@@ -412,10 +409,10 @@ ConfigParser.prototype = {
plugin.spec = pluginElement.attrib.spec || pluginElement.attrib.src || pluginElement.attrib.version;
plugin.variables = {};
var variableElements = pluginElement.findall('variable');
- variableElements.forEach(function(varElement){
+ variableElements.forEach(function (varElement) {
var name = varElement.attrib.name;
var value = varElement.attrib.value;
- if(name){
+ if (name) {
plugin.variables[name] = value;
}
});
@@ -430,8 +427,8 @@ ConfigParser.prototype = {
* @function
* @param id name of the plugin
*/
- removePlugin: function(id){
- if(id){
+ removePlugin: function (id) {
+ if (id) {
var plugins = this.doc.findall('./plugin/[@name="' + id + '"]')
.concat(this.doc.findall('./feature/param[@name="id"][@value="' + id + '"]/..'));
var children = this.doc.getroot().getchildren();
@@ -445,7 +442,7 @@ ConfigParser.prototype = {
},
// Add any element to the root
- addElement: function(name, attributes) {
+ addElement: function (name, attributes) {
var el = et.Element(name);
for (var a in attributes) {
el.attrib[a] = attributes[a];
@@ -458,11 +455,11 @@ ConfigParser.prototype = {
* @param {String} name the engine name
* @param {String} spec engine source location or version (optional)
*/
- addEngine: function(name, spec){
- if(!name) return;
+ addEngine: function (name, spec) {
+ if (!name) return;
var el = et.Element('engine');
el.attrib.name = name;
- if(spec){
+ if (spec) {
el.attrib.spec = spec;
}
this.doc.getroot().append(el);
@@ -471,52 +468,52 @@ ConfigParser.prototype = {
* Removes all the engines with given name
* @param {String} name the engine name.
*/
- removeEngine: function(name){
- var engines = this.doc.findall('./engine/[@name="' +name+'"]');
- for(var i=0; i < engines.length; i++){
+ removeEngine: function (name) {
+ var engines = this.doc.findall('./engine/[@name="' + name + '"]');
+ for (var i = 0; i < engines.length; i++) {
var children = this.doc.getroot().getchildren();
var idx = children.indexOf(engines[i]);
- if(idx > -1){
- children.splice(idx,1);
+ if (idx > -1) {
+ children.splice(idx, 1);
}
}
},
- getEngines: function(){
+ getEngines: function () {
var engines = this.doc.findall('./engine');
- return engines.map(function(engine){
+ return engines.map(function (engine) {
var spec = engine.attrib.spec || engine.attrib.version;
return {
'name': engine.attrib.name,
- 'spec': spec ? spec : null
+ 'spec': spec || null
};
});
},
/* Get all the access tags */
- getAccesses: function() {
+ getAccesses: function () {
var accesses = this.doc.findall('./access');
- return accesses.map(function(access){
+ return accesses.map(function (access) {
var minimum_tls_version = access.attrib['minimum-tls-version']; /* String */
var requires_forward_secrecy = access.attrib['requires-forward-secrecy']; /* Boolean */
var requires_certificate_transparency = access.attrib['requires-certificate-transparency']; /* Boolean */
var allows_arbitrary_loads_in_web_content = access.attrib['allows-arbitrary-loads-in-web-content']; /* Boolean */
var allows_arbitrary_loads_in_media = access.attrib['allows-arbitrary-loads-in-media']; /* Boolean */
var allows_local_networking = access.attrib['allows-local-networking']; /* Boolean */
-
+
return {
'origin': access.attrib.origin,
'minimum_tls_version': minimum_tls_version,
- 'requires_forward_secrecy' : requires_forward_secrecy,
- 'requires_certificate_transparency' : requires_certificate_transparency,
- 'allows_arbitrary_loads_in_web_content' : allows_arbitrary_loads_in_web_content,
- 'allows_arbitrary_loads_in_media' : allows_arbitrary_loads_in_media,
- 'allows_local_networking' : allows_local_networking
+ 'requires_forward_secrecy': requires_forward_secrecy,
+ 'requires_certificate_transparency': requires_certificate_transparency,
+ 'allows_arbitrary_loads_in_web_content': allows_arbitrary_loads_in_web_content,
+ 'allows_arbitrary_loads_in_media': allows_arbitrary_loads_in_media,
+ 'allows_local_networking': allows_local_networking
};
});
},
/* Get all the allow-navigation tags */
- getAllowNavigations: function() {
+ getAllowNavigations: function () {
var allow_navigations = this.doc.findall('./allow-navigation');
- return allow_navigations.map(function(allow_navigation){
+ return allow_navigations.map(function (allow_navigation) {
var minimum_tls_version = allow_navigation.attrib['minimum-tls-version']; /* String */
var requires_forward_secrecy = allow_navigation.attrib['requires-forward-secrecy']; /* Boolean */
var requires_certificate_transparency = allow_navigation.attrib['requires-certificate-transparency']; /* Boolean */
@@ -524,45 +521,45 @@ ConfigParser.prototype = {
return {
'href': allow_navigation.attrib.href,
'minimum_tls_version': minimum_tls_version,
- 'requires_forward_secrecy' : requires_forward_secrecy,
- 'requires_certificate_transparency' : requires_certificate_transparency
+ 'requires_forward_secrecy': requires_forward_secrecy,
+ 'requires_certificate_transparency': requires_certificate_transparency
};
});
},
/* Get all the allow-intent tags */
- getAllowIntents: function() {
+ getAllowIntents: function () {
var allow_intents = this.doc.findall('./allow-intent');
- return allow_intents.map(function(allow_intent){
+ return allow_intents.map(function (allow_intent) {
return {
'href': allow_intent.attrib.href
};
});
},
/* Get all edit-config tags */
- getEditConfigs: function(platform) {
+ getEditConfigs: function (platform) {
var platform_tag = this.doc.find('./platform[@name="' + platform + '"]');
var platform_edit_configs = platform_tag ? platform_tag.findall('edit-config') : [];
var edit_configs = this.doc.findall('edit-config').concat(platform_edit_configs);
- return edit_configs.map(function(tag) {
+ return edit_configs.map(function (tag) {
var editConfig =
{
- file : tag.attrib['file'],
- target : tag.attrib['target'],
- mode : tag.attrib['mode'],
- id : 'config.xml',
- xmls : tag.getchildren()
+ file: tag.attrib['file'],
+ target: tag.attrib['target'],
+ mode: tag.attrib['mode'],
+ id: 'config.xml',
+ xmls: tag.getchildren()
};
return editConfig;
});
},
- write:function() {
+ write: function () {
fs.writeFileSync(this.path, this.doc.write({indent: 4}), 'utf-8');
}
};
-function featureToPlugin(featureElement) {
+function featureToPlugin (featureElement) {
var plugin = {};
plugin.variables = [];
var pluginVersion,
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/CordovaCheck.js
----------------------------------------------------------------------
diff --git a/src/CordovaCheck.js b/src/CordovaCheck.js
index 46e733f..28f629d 100644
--- a/src/CordovaCheck.js
+++ b/src/CordovaCheck.js
@@ -17,10 +17,10 @@
under the License.
*/
-var fs = require('fs'),
- path = require('path');
+var fs = require('fs');
+var path = require('path');
-function isRootDir(dir) {
+function isRootDir (dir) {
if (fs.existsSync(path.join(dir, 'www'))) {
if (fs.existsSync(path.join(dir, 'config.xml'))) {
// For sure is.
@@ -41,12 +41,12 @@ function isRootDir(dir) {
// Runs up the directory chain looking for a .cordova directory.
// IF it is found we are in a Cordova project.
// Omit argument to use CWD.
-function isCordova(dir) {
+function isCordova (dir) {
if (!dir) {
// Prefer PWD over cwd so that symlinked dirs within your PWD work correctly (CB-5687).
var pwd = process.env.PWD;
var cwd = process.cwd();
- if (pwd && pwd != cwd && pwd != 'undefined') {
+ if (pwd && pwd !== cwd && pwd !== 'undefined') {
return isCordova(pwd) || isCordova(cwd);
}
return isCordova(cwd);
@@ -62,7 +62,7 @@ function isCordova(dir) {
}
var parentDir = path.normalize(path.join(dir, '..'));
// Detect fs root.
- if (parentDir == dir) {
+ if (parentDir === dir) {
return bestReturnValueSoFar;
}
dir = parentDir;
@@ -72,5 +72,5 @@ function isCordova(dir) {
}
module.exports = {
- findProjectRoot : isCordova
+ findProjectRoot: isCordova
};
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/CordovaError/CordovaError.js
----------------------------------------------------------------------
diff --git a/src/CordovaError/CordovaError.js b/src/CordovaError/CordovaError.js
index 7262448..24de6af 100644
--- a/src/CordovaError/CordovaError.js
+++ b/src/CordovaError/CordovaError.js
@@ -17,7 +17,7 @@
under the License.
*/
-/* jshint proto:true */
+/* eslint no-proto: 0 */
var EOL = require('os').EOL;
@@ -30,7 +30,7 @@ var EOL = require('os').EOL;
* @param {CordovaExternalToolErrorContext} [context] External tool error context object
* @constructor
*/
-function CordovaError(message, code, context) {
+function CordovaError (message, code, context) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
@@ -47,10 +47,10 @@ CordovaError.EXTERNAL_TOOL_ERROR = 1;
* Translates instance's error code number into error code name, e.g. 0 -> UNKNOWN_ERROR
* @returns {string} Error code string name
*/
-CordovaError.prototype.getErrorCodeName = function() {
- for(var key in CordovaError) {
- if(CordovaError.hasOwnProperty(key)) {
- if(CordovaError[key] === this.code) {
+CordovaError.prototype.getErrorCodeName = function () {
+ for (var key in CordovaError) {
+ if (CordovaError.hasOwnProperty(key)) {
+ if (CordovaError[key] === this.code) {
return key;
}
}
@@ -63,16 +63,17 @@ CordovaError.prototype.getErrorCodeName = function() {
* details including information about error code name and context
* @return {String} Stringified error representation
*/
-CordovaError.prototype.toString = function(isVerbose) {
- var message = '', codePrefix = '';
+CordovaError.prototype.toString = function (isVerbose) {
+ var message = '';
+ var codePrefix = '';
- if(this.code !== CordovaError.UNKNOWN_ERROR) {
+ if (this.code !== CordovaError.UNKNOWN_ERROR) {
codePrefix = 'code: ' + this.code + (isVerbose ? (' (' + this.getErrorCodeName() + ')') : '') + ' ';
}
- if(this.code === CordovaError.EXTERNAL_TOOL_ERROR) {
- if(typeof this.context !== 'undefined') {
- if(isVerbose) {
+ if (this.code === CordovaError.EXTERNAL_TOOL_ERROR) {
+ if (typeof this.context !== 'undefined') {
+ if (isVerbose) {
message = codePrefix + EOL + this.context.toString(isVerbose) + '\n failed with an error: ' +
this.message + EOL + 'Stack trace: ' + this.stack;
} else {
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/CordovaError/CordovaExternalToolErrorContext.js
----------------------------------------------------------------------
diff --git a/src/CordovaError/CordovaExternalToolErrorContext.js b/src/CordovaError/CordovaExternalToolErrorContext.js
index ca9a4aa..30699b4 100644
--- a/src/CordovaError/CordovaExternalToolErrorContext.js
+++ b/src/CordovaError/CordovaExternalToolErrorContext.js
@@ -27,7 +27,7 @@ var path = require('path');
* @param {String} [cwd] Command working directory
* @constructor
*/
-function CordovaExternalToolErrorContext(cmd, args, cwd) {
+function CordovaExternalToolErrorContext (cmd, args, cwd) {
this.cmd = cmd;
// Helper field for readability
this.cmdShortName = path.basename(cmd);
@@ -35,8 +35,8 @@ function CordovaExternalToolErrorContext(cmd, args, cwd) {
this.cwd = cwd;
}
-CordovaExternalToolErrorContext.prototype.toString = function(isVerbose) {
- if(isVerbose) {
+CordovaExternalToolErrorContext.prototype.toString = function (isVerbose) {
+ if (isVerbose) {
return 'External tool \'' + this.cmdShortName + '\'' +
'\nCommand full path: ' + this.cmd + '\nCommand args: ' + this.args +
(typeof this.cwd !== 'undefined' ? '\nCommand cwd: ' + this.cwd : '');
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/CordovaLogger.js
----------------------------------------------------------------------
diff --git a/src/CordovaLogger.js b/src/CordovaLogger.js
index dc49a4b..4d77608 100644
--- a/src/CordovaLogger.js
+++ b/src/CordovaLogger.js
@@ -41,11 +41,11 @@ function CordovaLogger () {
this.stderrCursor = ansi(this.stderr);
this.addLevel('verbose', 1000, 'grey');
- this.addLevel('normal' , 2000);
- this.addLevel('warn' , 2000, 'yellow');
- this.addLevel('info' , 3000, 'blue');
- this.addLevel('error' , 5000, 'red');
- this.addLevel('results' , 10000);
+ this.addLevel('normal', 2000);
+ this.addLevel('warn', 2000, 'yellow');
+ this.addLevel('info', 3000, 'blue');
+ this.addLevel('error', 5000, 'red');
+ this.addLevel('results', 10000);
this.setLevel('normal');
}
@@ -82,9 +82,10 @@ CordovaLogger.RESULTS = 'results';
CordovaLogger.prototype.log = function (logLevel, message) {
// if there is no such logLevel defined, or provided level has
// less severity than active level, then just ignore this call and return
- if (!this.levels[logLevel] || this.levels[logLevel] < this.levels[this.logLevel])
+ if (!this.levels[logLevel] || this.levels[logLevel] < this.levels[this.logLevel]) {
// return instance to allow to chain calls
return this;
+ }
var isVerbose = this.logLevel === 'verbose';
var cursor = this.stdoutCursor;
@@ -179,8 +180,7 @@ CordovaLogger.prototype.adjustLevel = function (opts) {
*/
CordovaLogger.prototype.subscribe = function (eventEmitter) {
- if (!(eventEmitter instanceof EventEmitter))
- throw new Error('Subscribe method only accepts an EventEmitter instance as argument');
+ if (!(eventEmitter instanceof EventEmitter)) { throw new Error('Subscribe method only accepts an EventEmitter instance as argument'); }
eventEmitter.on('verbose', this.verbose)
.on('log', this.normal)
@@ -193,7 +193,7 @@ CordovaLogger.prototype.subscribe = function (eventEmitter) {
return this;
};
-function formatError(error, isVerbose) {
+function formatError (error, isVerbose) {
var message = '';
if (error instanceof CordovaError) {
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/FileUpdater.js
----------------------------------------------------------------------
diff --git a/src/FileUpdater.js b/src/FileUpdater.js
index 8b6876b..c4eeb97 100644
--- a/src/FileUpdater.js
+++ b/src/FileUpdater.js
@@ -17,12 +17,12 @@
under the License.
*/
-"use strict";
+'use strict';
-var fs = require("fs");
-var path = require("path");
-var shell = require("shelljs");
-var minimatch = require("minimatch");
+var fs = require('fs');
+var path = require('path');
+var shell = require('shelljs');
+var minimatch = require('minimatch');
/**
* Logging callback used in the FileUpdater methods.
@@ -55,27 +55,27 @@ var minimatch = require("minimatch");
* @return {boolean} true if any changes were made, or false if the force flag is not set
* and everything was up to date
*/
-function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, options, log) {
+function updatePathWithStats (sourcePath, sourceStats, targetPath, targetStats, options, log) {
var updated = false;
- var rootDir = (options && options.rootDir) || "";
+ var rootDir = (options && options.rootDir) || '';
var copyAll = (options && options.all) || false;
- var targetFullPath = path.join(rootDir || "", targetPath);
+ var targetFullPath = path.join(rootDir || '', targetPath);
if (sourceStats) {
- var sourceFullPath = path.join(rootDir || "", sourcePath);
+ var sourceFullPath = path.join(rootDir || '', sourcePath);
if (targetStats) {
// The target exists. But if the directory status doesn't match the source, delete it.
if (targetStats.isDirectory() && !sourceStats.isDirectory()) {
- log("rmdir " + targetPath + " (source is a file)");
- shell.rm("-rf", targetFullPath);
+ log('rmdir ' + targetPath + ' (source is a file)');
+ shell.rm('-rf', targetFullPath);
targetStats = null;
updated = true;
} else if (!targetStats.isDirectory() && sourceStats.isDirectory()) {
- log("delete " + targetPath + " (source is a directory)");
- shell.rm("-f", targetFullPath);
+ log('delete ' + targetPath + ' (source is a directory)');
+ shell.rm('-f', targetFullPath);
targetStats = null;
updated = true;
}
@@ -84,21 +84,21 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
if (!targetStats) {
if (sourceStats.isDirectory()) {
// The target directory does not exist, so it should be created.
- log("mkdir " + targetPath);
- shell.mkdir("-p", targetFullPath);
+ log('mkdir ' + targetPath);
+ shell.mkdir('-p', targetFullPath);
updated = true;
} else if (sourceStats.isFile()) {
// The target file does not exist, so it should be copied from the source.
- log("copy " + sourcePath + " " + targetPath + (copyAll ? "" : " (new file)"));
- shell.cp("-f", sourceFullPath, targetFullPath);
+ log('copy ' + sourcePath + ' ' + targetPath + (copyAll ? '' : ' (new file)'));
+ shell.cp('-f', sourceFullPath, targetFullPath);
updated = true;
}
} else if (sourceStats.isFile() && targetStats.isFile()) {
// The source and target paths both exist and are files.
if (copyAll) {
// The caller specified all files should be copied.
- log("copy " + sourcePath + " " + targetPath);
- shell.cp("-f", sourceFullPath, targetFullPath);
+ log('copy ' + sourcePath + ' ' + targetPath);
+ shell.cp('-f', sourceFullPath, targetFullPath);
updated = true;
} else {
// Copy if the source has been modified since it was copied to the target, or if
@@ -107,8 +107,8 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
// for timestamps lacking sub-second precision in some filesystems.
if (sourceStats.mtime.getTime() >= targetStats.mtime.getTime() ||
sourceStats.size !== targetStats.size) {
- log("copy " + sourcePath + " " + targetPath + " (updated file)");
- shell.cp("-f", sourceFullPath, targetFullPath);
+ log('copy ' + sourcePath + ' ' + targetPath + ' (updated file)');
+ shell.cp('-f', sourceFullPath, targetFullPath);
updated = true;
}
}
@@ -116,11 +116,11 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
} else if (targetStats) {
// The target exists but the source is null, so the target should be deleted.
if (targetStats.isDirectory()) {
- log("rmdir " + targetPath + (copyAll ? "" : " (no source)"));
- shell.rm("-rf", targetFullPath);
+ log('rmdir ' + targetPath + (copyAll ? '' : ' (no source)'));
+ shell.rm('-rf', targetFullPath);
} else {
- log("delete " + targetPath + (copyAll ? "" : " (no source)"));
- shell.rm("-f", targetFullPath);
+ log('delete ' + targetPath + (copyAll ? '' : ' (no source)'));
+ shell.rm('-f', targetFullPath);
}
updated = true;
}
@@ -132,8 +132,8 @@ function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, o
* Helper for updatePath and updatePaths functions. Queries stats for source and target
* and ensures target directory exists before copying a file.
*/
-function updatePathInternal(sourcePath, targetPath, options, log) {
- var rootDir = (options && options.rootDir) || "";
+function updatePathInternal (sourcePath, targetPath, options, log) {
+ var rootDir = (options && options.rootDir) || '';
var targetFullPath = path.join(rootDir, targetPath);
var targetStats = fs.existsSync(targetFullPath) ? fs.statSync(targetFullPath) : null;
var sourceStats = null;
@@ -142,7 +142,7 @@ function updatePathInternal(sourcePath, targetPath, options, log) {
// A non-null source path was specified. It should exist.
var sourceFullPath = path.join(rootDir, sourcePath);
if (!fs.existsSync(sourceFullPath)) {
- throw new Error("Source path does not exist: " + sourcePath);
+ throw new Error('Source path does not exist: ' + sourcePath);
}
sourceStats = fs.statSync(sourceFullPath);
@@ -150,7 +150,7 @@ function updatePathInternal(sourcePath, targetPath, options, log) {
// Create the target's parent directory if it doesn't exist.
var parentDir = path.dirname(targetFullPath);
if (!fs.existsSync(parentDir)) {
- shell.mkdir("-p", parentDir);
+ shell.mkdir('-p', parentDir);
}
}
@@ -177,16 +177,16 @@ function updatePathInternal(sourcePath, targetPath, options, log) {
* @return {boolean} true if any changes were made, or false if the force flag is not set
* and everything was up to date
*/
-function updatePath(sourcePath, targetPath, options, log) {
- if (sourcePath !== null && typeof sourcePath !== "string") {
- throw new Error("A source path (or null) is required.");
+function updatePath (sourcePath, targetPath, options, log) {
+ if (sourcePath !== null && typeof sourcePath !== 'string') {
+ throw new Error('A source path (or null) is required.');
}
- if (!targetPath || typeof targetPath !== "string") {
- throw new Error("A target path is required.");
+ if (!targetPath || typeof targetPath !== 'string') {
+ throw new Error('A target path is required.');
}
- log = log || function(message) { };
+ log = log || function (message) { };
return updatePathInternal(sourcePath, targetPath, options, log);
}
@@ -208,12 +208,12 @@ function updatePath(sourcePath, targetPath, options, log) {
* @return {boolean} true if any changes were made, or false if the force flag is not set
* and everything was up to date
*/
-function updatePaths(pathMap, options, log) {
- if (!pathMap || typeof pathMap !== "object" || Array.isArray(pathMap)) {
- throw new Error("An object mapping from target paths to source paths is required.");
+function updatePaths (pathMap, options, log) {
+ if (!pathMap || typeof pathMap !== 'object' || Array.isArray(pathMap)) {
+ throw new Error('An object mapping from target paths to source paths is required.');
}
- log = log || function(message) { };
+ log = log || function (message) { };
var updated = false;
@@ -255,44 +255,44 @@ function updatePaths(pathMap, options, log) {
* @return {boolean} true if any changes were made, or false if the force flag is not set
* and everything was up to date
*/
-function mergeAndUpdateDir(sourceDirs, targetDir, options, log) {
- if (sourceDirs && typeof sourceDirs === "string") {
+function mergeAndUpdateDir (sourceDirs, targetDir, options, log) {
+ if (sourceDirs && typeof sourceDirs === 'string') {
sourceDirs = [ sourceDirs ];
} else if (!Array.isArray(sourceDirs)) {
- throw new Error("A source directory path or array of paths is required.");
+ throw new Error('A source directory path or array of paths is required.');
}
- if (!targetDir || typeof targetDir !== "string") {
- throw new Error("A target directory path is required.");
+ if (!targetDir || typeof targetDir !== 'string') {
+ throw new Error('A target directory path is required.');
}
- log = log || function(message) { };
+ log = log || function (message) { };
- var rootDir = (options && options.rootDir) || "";
+ var rootDir = (options && options.rootDir) || '';
- var include = (options && options.include) || [ "**" ];
- if (typeof include === "string") {
+ var include = (options && options.include) || [ '**' ];
+ if (typeof include === 'string') {
include = [ include ];
} else if (!Array.isArray(include)) {
- throw new Error("Include parameter must be a glob string or array of glob strings.");
+ throw new Error('Include parameter must be a glob string or array of glob strings.');
}
var exclude = (options && options.exclude) || [];
- if (typeof exclude === "string") {
+ if (typeof exclude === 'string') {
exclude = [ exclude ];
} else if (!Array.isArray(exclude)) {
- throw new Error("Exclude parameter must be a glob string or array of glob strings.");
+ throw new Error('Exclude parameter must be a glob string or array of glob strings.');
}
// Scan the files in each of the source directories.
var sourceMaps = sourceDirs.map(function (sourceDir) {
- return path.join(rootDir, sourceDir);
- }).map(function (sourcePath) {
- if (!fs.existsSync(sourcePath)) {
- throw new Error("Source directory does not exist: " + sourcePath);
- }
- return mapDirectory(rootDir, path.relative(rootDir, sourcePath), include, exclude);
- });
+ return path.join(rootDir, sourceDir);
+ }).map(function (sourcePath) {
+ if (!fs.existsSync(sourcePath)) {
+ throw new Error('Source directory does not exist: ' + sourcePath);
+ }
+ return mapDirectory(rootDir, path.relative(rootDir, sourcePath), include, exclude);
+ });
// Scan the files in the target directory, if it exists.
var targetMap = {};
@@ -323,18 +323,18 @@ function mergeAndUpdateDir(sourceDirs, targetDir, options, log) {
/**
* Creates a dictionary map of all files and directories under a path.
*/
-function mapDirectory(rootDir, subDir, include, exclude) {
- var dirMap = { "": { subDir: subDir, stats: fs.statSync(path.join(rootDir, subDir)) } };
- mapSubdirectory(rootDir, subDir, "", include, exclude, dirMap);
+function mapDirectory (rootDir, subDir, include, exclude) {
+ var dirMap = { '': { subDir: subDir, stats: fs.statSync(path.join(rootDir, subDir)) } };
+ mapSubdirectory(rootDir, subDir, '', include, exclude, dirMap);
return dirMap;
- function mapSubdirectory(rootDir, subDir, relativeDir, include, exclude, dirMap) {
+ function mapSubdirectory (rootDir, subDir, relativeDir, include, exclude, dirMap) {
var itemMapped = false;
var items = fs.readdirSync(path.join(rootDir, subDir, relativeDir));
- items.forEach(function(item) {
+ items.forEach(function (item) {
var relativePath = path.join(relativeDir, item);
- if(!matchGlobArray(relativePath, exclude)) {
+ if (!matchGlobArray(relativePath, exclude)) {
// Stats obtained here (required at least to know where to recurse in directories)
// are saved for later, where the modified times may also be used. This minimizes
// the number of file I/O operations performed.
@@ -361,9 +361,9 @@ function mapDirectory(rootDir, subDir, include, exclude) {
return itemMapped;
}
- function matchGlobArray(path, globs) {
- return globs.some(function(elem) {
- return minimatch(path, elem, {dot:true});
+ function matchGlobArray (path, globs) {
+ return globs.some(function (elem) {
+ return minimatch(path, elem, {dot: true});
});
}
}
@@ -372,13 +372,13 @@ function mapDirectory(rootDir, subDir, include, exclude) {
* Merges together multiple source maps and a target map into a single mapping from
* relative paths to objects with target and source paths and stats.
*/
-function mergePathMaps(sourceMaps, targetMap, targetDir) {
+function mergePathMaps (sourceMaps, targetMap, targetDir) {
// Merge multiple source maps together, along with target path info.
// Entries in later source maps override those in earlier source maps.
// Target stats will be filled in below for targets that exist.
var pathMap = {};
sourceMaps.forEach(function (sourceMap) {
- Object.keys(sourceMap).forEach(function(sourceSubPath){
+ Object.keys(sourceMap).forEach(function (sourceSubPath) {
var sourceEntry = sourceMap[sourceSubPath];
pathMap[sourceSubPath] = {
targetPath: path.join(targetDir, sourceSubPath),
@@ -391,7 +391,7 @@ function mergePathMaps(sourceMaps, targetMap, targetDir) {
// Fill in target stats for targets that exist, and create entries
// for targets that don't have any corresponding sources.
- Object.keys(targetMap).forEach(function(subPath){
+ Object.keys(targetMap).forEach(function (subPath) {
var entry = pathMap[subPath];
if (entry) {
entry.targetStats = targetMap[subPath].stats;
@@ -413,4 +413,3 @@ module.exports = {
updatePaths: updatePaths,
mergeAndUpdateDir: mergeAndUpdateDir
};
-
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/PlatformJson.js
----------------------------------------------------------------------
diff --git a/src/PlatformJson.js b/src/PlatformJson.js
index 137bd21..7eaf1a2 100644
--- a/src/PlatformJson.js
+++ b/src/PlatformJson.js
@@ -13,7 +13,6 @@
* under the License.
*
*/
-/* jshint sub:true */
var fs = require('fs');
var path = require('path');
@@ -22,13 +21,13 @@ var mungeutil = require('./ConfigChanges/munge-util');
var pluginMappernto = require('cordova-registry-mapper').newToOld;
var pluginMapperotn = require('cordova-registry-mapper').oldToNew;
-function PlatformJson(filePath, platform, root) {
+function PlatformJson (filePath, platform, root) {
this.filePath = filePath;
this.platform = platform;
this.root = fix_munge(root || {});
}
-PlatformJson.load = function(plugins_dir, platform) {
+PlatformJson.load = function (plugins_dir, platform) {
var filePath = path.join(plugins_dir, platform + '.json');
var root = null;
if (fs.existsSync(filePath)) {
@@ -37,7 +36,7 @@ PlatformJson.load = function(plugins_dir, platform) {
return new PlatformJson(filePath, platform, root);
};
-PlatformJson.prototype.save = function() {
+PlatformJson.prototype.save = function () {
shelljs.mkdir('-p', path.dirname(this.filePath));
fs.writeFileSync(this.filePath, JSON.stringify(this.root, null, 2), 'utf-8');
};
@@ -49,7 +48,7 @@ PlatformJson.prototype.save = function() {
* @param {String} pluginId A plugin id to check for.
* @return {Boolean} true if plugin installed as top-level, otherwise false.
*/
-PlatformJson.prototype.isPluginTopLevel = function(pluginId) {
+PlatformJson.prototype.isPluginTopLevel = function (pluginId) {
var installedPlugins = this.root.installed_plugins;
return installedPlugins[pluginId] ||
installedPlugins[pluginMappernto[pluginId]] ||
@@ -63,7 +62,7 @@ PlatformJson.prototype.isPluginTopLevel = function(pluginId) {
* @param {String} pluginId A plugin id to check for.
* @return {Boolean} true if plugin installed as a dependency, otherwise false.
*/
-PlatformJson.prototype.isPluginDependent = function(pluginId) {
+PlatformJson.prototype.isPluginDependent = function (pluginId) {
var dependentPlugins = this.root.dependent_plugins;
return dependentPlugins[pluginId] ||
dependentPlugins[pluginMappernto[pluginId]] ||
@@ -76,12 +75,12 @@ PlatformJson.prototype.isPluginDependent = function(pluginId) {
* @param {String} pluginId A plugin id to check for.
* @return {Boolean} true if plugin installed, otherwise false.
*/
-PlatformJson.prototype.isPluginInstalled = function(pluginId) {
+PlatformJson.prototype.isPluginInstalled = function (pluginId) {
return this.isPluginTopLevel(pluginId) ||
this.isPluginDependent(pluginId);
};
-PlatformJson.prototype.addPlugin = function(pluginId, variables, isTopLevel) {
+PlatformJson.prototype.addPlugin = function (pluginId, variables, isTopLevel) {
var pluginsList = isTopLevel ?
this.root.installed_plugins :
this.root.dependent_plugins;
@@ -107,13 +106,13 @@ PlatformJson.prototype.addPluginMetadata = function (pluginInfo) {
});
var modulesToInstall = pluginInfo.getJsModules(this.platform)
- .map(function (module) {
- return new ModuleMetadata(pluginInfo.id, module);
- })
- .filter(function (metadata) {
- // Filter out modules which are already added to metadata
- return installedPaths.indexOf(metadata.file) === -1;
- });
+ .map(function (module) {
+ return new ModuleMetadata(pluginInfo.id, module);
+ })
+ .filter(function (metadata) {
+ // Filter out modules which are already added to metadata
+ return installedPaths.indexOf(metadata.file) === -1;
+ });
this.root.modules = installedModules.concat(modulesToInstall);
@@ -123,7 +122,7 @@ PlatformJson.prototype.addPluginMetadata = function (pluginInfo) {
return this;
};
-PlatformJson.prototype.removePlugin = function(pluginId, isTopLevel) {
+PlatformJson.prototype.removePlugin = function (pluginId, isTopLevel) {
var pluginsList = isTopLevel ?
this.root.installed_plugins :
this.root.dependent_plugins;
@@ -144,16 +143,16 @@ PlatformJson.prototype.removePlugin = function(pluginId, isTopLevel) {
*/
PlatformJson.prototype.removePluginMetadata = function (pluginInfo) {
var modulesToRemove = pluginInfo.getJsModules(this.platform)
- .map(function (jsModule) {
- return ['plugins', pluginInfo.id, jsModule.src].join('/');
- });
+ .map(function (jsModule) {
+ return ['plugins', pluginInfo.id, jsModule.src].join('/');
+ });
var installedModules = this.root.modules || [];
this.root.modules = installedModules
- .filter(function (installedModule) {
- // Leave only those metadatas which 'file' is not in removed modules
- return (modulesToRemove.indexOf(installedModule.file) === -1);
- });
+ .filter(function (installedModule) {
+ // Leave only those metadatas which 'file' is not in removed modules
+ return (modulesToRemove.indexOf(installedModule.file) === -1);
+ });
if (this.root.plugin_metadata) {
delete this.root.plugin_metadata[pluginInfo.id];
@@ -162,12 +161,12 @@ PlatformJson.prototype.removePluginMetadata = function (pluginInfo) {
return this;
};
-PlatformJson.prototype.addInstalledPluginToPrepareQueue = function(pluginDirName, vars, is_top_level, force) {
- this.root.prepare_queue.installed.push({'plugin':pluginDirName, 'vars':vars, 'topLevel':is_top_level, 'force':force});
+PlatformJson.prototype.addInstalledPluginToPrepareQueue = function (pluginDirName, vars, is_top_level, force) {
+ this.root.prepare_queue.installed.push({'plugin': pluginDirName, 'vars': vars, 'topLevel': is_top_level, 'force': force});
};
-PlatformJson.prototype.addUninstalledPluginToPrepareQueue = function(pluginId, is_top_level) {
- this.root.prepare_queue.uninstalled.push({'plugin':pluginId, 'id':pluginId, 'topLevel':is_top_level});
+PlatformJson.prototype.addUninstalledPluginToPrepareQueue = function (pluginId, is_top_level) {
+ this.root.prepare_queue.uninstalled.push({'plugin': pluginId, 'id': pluginId, 'topLevel': is_top_level});
};
/**
@@ -177,7 +176,7 @@ PlatformJson.prototype.addUninstalledPluginToPrepareQueue = function(pluginId, i
* @param {String} pluginId A plugin id to make top-level.
* @return {PlatformJson} PlatformJson instance.
*/
-PlatformJson.prototype.makeTopLevel = function(pluginId) {
+PlatformJson.prototype.makeTopLevel = function (pluginId) {
var plugin = this.root.dependent_plugins[pluginId];
if (plugin) {
delete this.root.dependent_plugins[pluginId];
@@ -220,8 +219,8 @@ PlatformJson.prototype.generateAndSaveMetadata = function (destination) {
};
// convert a munge from the old format ([file][parent][xml] = count) to the current one
-function fix_munge(root) {
- root.prepare_queue = root.prepare_queue || {installed:[], uninstalled:[]};
+function fix_munge (root) {
+ root.prepare_queue = root.prepare_queue || {installed: [], uninstalled: []};
root.config_munge = root.config_munge || {files: {}};
root.installed_plugins = root.installed_plugins || {};
root.dependent_plugins = root.dependent_plugins || {};
@@ -260,15 +259,15 @@ function ModuleMetadata (pluginId, jsModule) {
if (!pluginId) throw new TypeError('pluginId argument must be a valid plugin id');
if (!jsModule.src && !jsModule.name) throw new TypeError('jsModule argument must contain src or/and name properties');
- this.id = pluginId + '.' + ( jsModule.name || jsModule.src.match(/([^\/]+)\.js/)[1] );
+ this.id = pluginId + '.' + (jsModule.name || jsModule.src.match(/([^\/]+)\.js/)[1]); /* eslint no-useless-escape: 0 */
this.file = ['plugins', pluginId, jsModule.src].join('/');
this.pluginId = pluginId;
if (jsModule.clobbers && jsModule.clobbers.length > 0) {
- this.clobbers = jsModule.clobbers.map(function(o) { return o.target; });
+ this.clobbers = jsModule.clobbers.map(function (o) { return o.target; });
}
if (jsModule.merges && jsModule.merges.length > 0) {
- this.merges = jsModule.merges.map(function(o) { return o.target; });
+ this.merges = jsModule.merges.map(function (o) { return o.target; });
}
if (jsModule.runs) {
this.runs = true;
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/PluginInfo/PluginInfo.js
----------------------------------------------------------------------
diff --git a/src/PluginInfo/PluginInfo.js b/src/PluginInfo/PluginInfo.js
index 4817470..75c96c1 100644
--- a/src/PluginInfo/PluginInfo.js
+++ b/src/PluginInfo/PluginInfo.js
@@ -17,8 +17,6 @@
under the License.
*/
-/* jshint sub:true, laxcomma:true, laxbreak:true */
-
/*
A class for holidng the information currently stored in plugin.xml
It should also be able to answer questions like whether the plugin
@@ -27,14 +25,12 @@ is compatible with a given engine version.
TODO (kamrik): refactor this to not use sync functions and return promises.
*/
+var path = require('path');
+var fs = require('fs');
+var xml_helpers = require('../util/xml-helpers');
+var CordovaError = require('../CordovaError/CordovaError');
-var path = require('path')
- , fs = require('fs')
- , xml_helpers = require('../util/xml-helpers')
- , CordovaError = require('../CordovaError/CordovaError')
- ;
-
-function PluginInfo(dirname) {
+function PluginInfo (dirname) {
var self = this;
// METHODS
@@ -45,15 +41,15 @@ function PluginInfo(dirname) {
// Used to require a variable to be specified via --variable when installing the plugin.
// returns { key : default | null}
self.getPreferences = getPreferences;
- function getPreferences(platform) {
+ function getPreferences (platform) {
return _getTags(self._et, 'preference', platform, _parsePreference)
- .reduce(function (preferences, pref) {
- preferences[pref.preference] = pref.default;
- return preferences;
- }, {});
+ .reduce(function (preferences, pref) {
+ preferences[pref.preference] = pref.default;
+ return preferences;
+ }, {});
}
- function _parsePreference(prefTag) {
+ function _parsePreference (prefTag) {
var name = prefTag.attrib.name.toUpperCase();
var def = prefTag.attrib.default || null;
return {preference: name, default: def};
@@ -61,16 +57,16 @@ function PluginInfo(dirname) {
// <asset>
self.getAssets = getAssets;
- function getAssets(platform) {
+ function getAssets (platform) {
var assets = _getTags(self._et, 'asset', platform, _parseAsset);
return assets;
}
- function _parseAsset(tag) {
+ function _parseAsset (tag) {
var src = tag.attrib.src;
var target = tag.attrib.target;
- if ( !src || !target) {
+ if (!src || !target) {
var msg =
'Malformed <asset> tag. Both "src" and "target" attributes'
+ 'must be specified in\n'
@@ -87,7 +83,6 @@ function PluginInfo(dirname) {
return asset;
}
-
// <dependency>
// Example:
// <dependency id="com.plugin.id"
@@ -95,28 +90,28 @@ function PluginInfo(dirname) {
// commit="428931ada3891801"
// subdir="some/path/here" />
self.getDependencies = getDependencies;
- function getDependencies(platform) {
+ function getDependencies (platform) {
var deps = _getTags(
- self._et,
- 'dependency',
- platform,
- _parseDependency
+ self._et,
+ 'dependency',
+ platform,
+ _parseDependency
);
return deps;
}
- function _parseDependency(tag) {
+ function _parseDependency (tag) {
var dep =
- { id : tag.attrib.id
- , version: tag.attrib.version || ''
- , url : tag.attrib.url || ''
- , subdir : tag.attrib.subdir || ''
- , commit : tag.attrib.commit
+ { id: tag.attrib.id,
+ version: tag.attrib.version || '',
+ url: tag.attrib.url || '',
+ subdir: tag.attrib.subdir || '',
+ commit: tag.attrib.commit
};
dep.git_ref = dep.commit;
- if ( !dep.id ) {
+ if (!dep.id) {
var msg =
'<dependency> tag is missing id attribute in '
+ self.filepath
@@ -126,52 +121,51 @@ function PluginInfo(dirname) {
return dep;
}
-
// <config-file> tag
self.getConfigFiles = getConfigFiles;
- function getConfigFiles(platform) {
+ function getConfigFiles (platform) {
var configFiles = _getTags(self._et, 'config-file', platform, _parseConfigFile);
return configFiles;
}
- function _parseConfigFile(tag) {
+ function _parseConfigFile (tag) {
var configFile =
- { target : tag.attrib['target']
- , parent : tag.attrib['parent']
- , after : tag.attrib['after']
- , xmls : tag.getchildren()
- // To support demuxing via versions
- , versions : tag.attrib['versions']
- , deviceTarget: tag.attrib['device-target']
+ { target: tag.attrib['target'],
+ parent: tag.attrib['parent'],
+ after: tag.attrib['after'],
+ xmls: tag.getchildren(),
+ // To support demuxing via versions
+ versions: tag.attrib['versions'],
+ deviceTarget: tag.attrib['device-target']
};
return configFile;
}
self.getEditConfigs = getEditConfigs;
- function getEditConfigs(platform) {
+ function getEditConfigs (platform) {
var editConfigs = _getTags(self._et, 'edit-config', platform, _parseEditConfigs);
return editConfigs;
}
- function _parseEditConfigs(tag) {
+ function _parseEditConfigs (tag) {
var editConfig =
- { file : tag.attrib['file']
- , target : tag.attrib['target']
- , mode : tag.attrib['mode']
- , xmls : tag.getchildren()
- };
+ { file: tag.attrib['file'],
+ target: tag.attrib['target'],
+ mode: tag.attrib['mode'],
+ xmls: tag.getchildren()
+ };
return editConfig;
}
// <info> tags, both global and within a <platform>
// TODO (kamrik): Do we ever use <info> under <platform>? Example wanted.
self.getInfo = getInfo;
- function getInfo(platform) {
+ function getInfo (platform) {
var infos = _getTags(
- self._et,
- 'info',
- platform,
- function(elem) { return elem.text; }
+ self._et,
+ 'info',
+ platform,
+ function (elem) { return elem.text; }
);
// Filter out any undefined or empty strings.
infos = infos.filter(Boolean);
@@ -183,12 +177,12 @@ function PluginInfo(dirname) {
// <source-file src="src/ios/someLib.a" framework="true" />
// <source-file src="src/ios/someLib.a" compiler-flags="-fno-objc-arc" />
self.getSourceFiles = getSourceFiles;
- function getSourceFiles(platform) {
+ function getSourceFiles (platform) {
var sourceFiles = _getTagsInPlatform(self._et, 'source-file', platform, _parseSourceFile);
return sourceFiles;
}
- function _parseSourceFile(tag) {
+ function _parseSourceFile (tag) {
return {
itemType: 'source-file',
src: tag.attrib.src,
@@ -203,8 +197,8 @@ function PluginInfo(dirname) {
// Example:
// <header-file src="CDVFoo.h" />
self.getHeaderFiles = getHeaderFiles;
- function getHeaderFiles(platform) {
- var headerFiles = _getTagsInPlatform(self._et, 'header-file', platform, function(tag) {
+ function getHeaderFiles (platform) {
+ var headerFiles = _getTagsInPlatform(self._et, 'header-file', platform, function (tag) {
return {
itemType: 'header-file',
src: tag.attrib.src,
@@ -218,8 +212,8 @@ function PluginInfo(dirname) {
// Example:
// <resource-file src="FooPluginStrings.xml" target="res/values/FooPluginStrings.xml" device-target="win" arch="x86" versions=">=8.1" />
self.getResourceFiles = getResourceFiles;
- function getResourceFiles(platform) {
- var resourceFiles = _getTagsInPlatform(self._et, 'resource-file', platform, function(tag) {
+ function getResourceFiles (platform) {
+ var resourceFiles = _getTagsInPlatform(self._et, 'resource-file', platform, function (tag) {
return {
itemType: 'resource-file',
src: tag.attrib.src,
@@ -237,8 +231,8 @@ function PluginInfo(dirname) {
// Example:
// <lib-file src="src/BlackBerry10/native/device/libfoo.so" arch="device" />
self.getLibFiles = getLibFiles;
- function getLibFiles(platform) {
- var libFiles = _getTagsInPlatform(self._et, 'lib-file', platform, function(tag) {
+ function getLibFiles (platform) {
+ var libFiles = _getTagsInPlatform(self._et, 'lib-file', platform, function (tag) {
return {
itemType: 'lib-file',
src: tag.attrib.src,
@@ -255,16 +249,16 @@ function PluginInfo(dirname) {
// Example:
// <hook type="before_build" src="scripts/beforeBuild.js" />
self.getHookScripts = getHookScripts;
- function getHookScripts(hook, platforms) {
- var scriptElements = self._et.findall('./hook');
+ function getHookScripts (hook, platforms) {
+ var scriptElements = self._et.findall('./hook');
- if(platforms) {
+ if (platforms) {
platforms.forEach(function (platform) {
scriptElements = scriptElements.concat(self._et.findall('./platform[@name="' + platform + '"]/hook'));
});
}
- function filterScriptByHookType(el) {
+ function filterScriptByHookType (el) {
return el.attrib.src && el.attrib.type && el.attrib.type.toLowerCase() === hook;
}
@@ -272,26 +266,26 @@ function PluginInfo(dirname) {
}
self.getJsModules = getJsModules;
- function getJsModules(platform) {
+ function getJsModules (platform) {
var modules = _getTags(self._et, 'js-module', platform, _parseJsModule);
return modules;
}
- function _parseJsModule(tag) {
+ function _parseJsModule (tag) {
var ret = {
itemType: 'js-module',
name: tag.attrib.name,
src: tag.attrib.src,
- clobbers: tag.findall('clobbers').map(function(tag) { return { target: tag.attrib.target }; }),
- merges: tag.findall('merges').map(function(tag) { return { target: tag.attrib.target }; }),
+ clobbers: tag.findall('clobbers').map(function (tag) { return { target: tag.attrib.target }; }),
+ merges: tag.findall('merges').map(function (tag) { return { target: tag.attrib.target }; }),
runs: tag.findall('runs').length > 0
};
return ret;
}
- self.getEngines = function() {
- return self._et.findall('engines/engine').map(function(n) {
+ self.getEngines = function () {
+ return self._et.findall('engines/engine').map(function (n) {
return {
name: n.attrib.name,
version: n.attrib.version,
@@ -301,19 +295,19 @@ function PluginInfo(dirname) {
});
};
- self.getPlatforms = function() {
- return self._et.findall('platform').map(function(n) {
+ self.getPlatforms = function () {
+ return self._et.findall('platform').map(function (n) {
return { name: n.attrib.name };
});
};
- self.getPlatformsArray = function() {
- return self._et.findall('platform').map(function(n) {
+ self.getPlatformsArray = function () {
+ return self._et.findall('platform').map(function (n) {
return n.attrib.name;
});
};
- self.getFrameworks = function(platform) {
- return _getTags(self._et, 'framework', platform, function(el) {
+ self.getFrameworks = function (platform) {
+ return _getTags(self._et, 'framework', platform, function (el) {
var ret = {
itemType: 'framework',
type: el.attrib.type,
@@ -334,7 +328,7 @@ function PluginInfo(dirname) {
};
self.getFilesAndFrameworks = getFilesAndFrameworks;
- function getFilesAndFrameworks(platform) {
+ function getFilesAndFrameworks (platform) {
// Please avoid changing the order of the calls below, files will be
// installed in this order.
var items = [].concat(
@@ -346,10 +340,9 @@ function PluginInfo(dirname) {
);
return items;
}
- ///// End of PluginInfo methods /////
-
+ /// // End of PluginInfo methods /////
- ///// PluginInfo Constructor logic /////
+ /// // PluginInfo Constructor logic /////
self.filepath = path.join(dirname, 'plugin.xml');
if (!fs.existsSync(self.filepath)) {
throw new CordovaError('Cannot find plugin.xml for plugin "' + path.basename(dirname) + '". Please try adding it again.');
@@ -370,18 +363,18 @@ function PluginInfo(dirname) {
self.keywords = pelem.findtext('keywords');
self.info = pelem.findtext('info');
if (self.keywords) {
- self.keywords = self.keywords.split(',').map( function(s) { return s.trim(); } );
+ self.keywords = self.keywords.split(',').map(function (s) { return s.trim(); });
}
self.getKeywordsAndPlatforms = function () {
var ret = self.keywords || [];
return ret.concat('ecosystem:cordova').concat(addCordova(self.getPlatformsArray()));
};
-} // End of PluginInfo constructor.
+} // End of PluginInfo constructor.
// Helper function used to prefix every element of an array with cordova-
// Useful when we want to modify platforms to be cordova-platform
-function addCordova(someArray) {
- var newArray = someArray.map(function(element) {
+function addCordova (someArray) {
+ var newArray = someArray.map(function (element) {
return 'cordova-' + element;
});
return newArray;
@@ -391,37 +384,37 @@ function addCordova(someArray) {
// Get all elements of a given name. Both in root and in platform sections
// for the given platform. If transform is given and is a function, it is
// applied to each element.
-function _getTags(pelem, tag, platform, transform) {
+function _getTags (pelem, tag, platform, transform) {
var platformTag = pelem.find('./platform[@name="' + platform + '"]');
var tagsInRoot = pelem.findall(tag);
tagsInRoot = tagsInRoot || [];
var tagsInPlatform = platformTag ? platformTag.findall(tag) : [];
var tags = tagsInRoot.concat(tagsInPlatform);
- if ( typeof transform === 'function' ) {
+ if (typeof transform === 'function') {
tags = tags.map(transform);
}
return tags;
}
// Same as _getTags() but only looks inside a platform section.
-function _getTagsInPlatform(pelem, tag, platform, transform) {
+function _getTagsInPlatform (pelem, tag, platform, transform) {
var platformTag = pelem.find('./platform[@name="' + platform + '"]');
var tags = platformTag ? platformTag.findall(tag) : [];
- if ( typeof transform === 'function' ) {
+ if (typeof transform === 'function') {
tags = tags.map(transform);
}
return tags;
}
// Check if x is a string 'true'.
-function isStrTrue(x) {
- return String(x).toLowerCase() == 'true';
+function isStrTrue (x) {
+ return String(x).toLowerCase() === 'true';
}
module.exports = PluginInfo;
// Backwards compat:
PluginInfo.PluginInfo = PluginInfo;
-PluginInfo.loadPluginsDir = function(dir) {
+PluginInfo.loadPluginsDir = function (dir) {
var PluginInfoProvider = require('./PluginInfoProvider');
return new PluginInfoProvider().getAllWithinSearchPath(dir);
};
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/PluginInfo/PluginInfoProvider.js
----------------------------------------------------------------------
diff --git a/src/PluginInfo/PluginInfoProvider.js b/src/PluginInfo/PluginInfoProvider.js
index 6240119..5d3f329 100644
--- a/src/PluginInfo/PluginInfoProvider.js
+++ b/src/PluginInfo/PluginInfoProvider.js
@@ -24,12 +24,12 @@ var path = require('path');
var PluginInfo = require('./PluginInfo');
var events = require('../events');
-function PluginInfoProvider() {
+function PluginInfoProvider () {
this._cache = {};
this._getAllCache = {};
}
-PluginInfoProvider.prototype.get = function(dirName) {
+PluginInfoProvider.prototype.get = function (dirName) {
var absPath = path.resolve(dirName);
if (!this._cache[absPath]) {
this._cache[absPath] = new PluginInfo(dirName);
@@ -39,7 +39,7 @@ PluginInfoProvider.prototype.get = function(dirName) {
// Normally you don't need to put() entries, but it's used
// when copying plugins, and in unit tests.
-PluginInfoProvider.prototype.put = function(pluginInfo) {
+PluginInfoProvider.prototype.put = function (pluginInfo) {
var absPath = path.resolve(pluginInfo.dir);
this._cache[absPath] = pluginInfo;
};
@@ -48,7 +48,7 @@ PluginInfoProvider.prototype.put = function(pluginInfo) {
// Given a dir containing multiple plugins, create a PluginInfo object for
// each of them and return as array.
// Should load them all in parallel and return a promise, but not yet.
-PluginInfoProvider.prototype.getAllWithinSearchPath = function(dirName) {
+PluginInfoProvider.prototype.getAllWithinSearchPath = function (dirName) {
var absPath = path.resolve(dirName);
if (!this._getAllCache[absPath]) {
this._getAllCache[absPath] = getAllHelper(absPath, this);
@@ -56,8 +56,8 @@ PluginInfoProvider.prototype.getAllWithinSearchPath = function(dirName) {
return this._getAllCache[absPath];
};
-function getAllHelper(absPath, provider) {
- if (!fs.existsSync(absPath)){
+function getAllHelper (absPath, provider) {
+ if (!fs.existsSync(absPath)) {
return [];
}
// If dir itself is a plugin, return it in an array with one element.
@@ -66,7 +66,7 @@ function getAllHelper(absPath, provider) {
}
var subdirs = fs.readdirSync(absPath);
var plugins = [];
- subdirs.forEach(function(subdir) {
+ subdirs.forEach(function (subdir) {
var d = path.join(absPath, subdir);
if (fs.existsSync(path.join(d, 'plugin.xml'))) {
try {
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/PluginManager.js
----------------------------------------------------------------------
diff --git a/src/PluginManager.js b/src/PluginManager.js
index 0bcaf59..7b8a0d4 100644
--- a/src/PluginManager.js
+++ b/src/PluginManager.js
@@ -36,7 +36,7 @@ var PluginInfoProvider = require('./PluginInfo/PluginInfoProvider');
* @param {Object} locations - Platform files and directories
* @param {IDEProject} ideProject The IDE project to add/remove plugin changes to/from
*/
-function PluginManager(platform, locations, ideProject) {
+function PluginManager (platform, locations, ideProject) {
this.platform = platform;
this.locations = locations;
this.project = ideProject;
@@ -45,7 +45,6 @@ function PluginManager(platform, locations, ideProject) {
this.munger = new PlatformMunger(platform, locations.root, platformJson, new PluginInfoProvider());
}
-
/**
* @constructs PluginManager
* A convenience shortcut to new PluginManager(...)
@@ -55,7 +54,7 @@ function PluginManager(platform, locations, ideProject) {
* @param {IDEProject} ideProject The IDE project to add/remove plugin changes to/from
* @returns new PluginManager instance
*/
-PluginManager.get = function(platform, locations, ideProject) {
+PluginManager.get = function (platform, locations, ideProject) {
return new PluginManager(platform, locations, ideProject);
};
@@ -82,11 +81,9 @@ module.exports = PluginManager;
* @returns {Promise} Returns a Q promise, either resolved in case of success, rejected otherwise.
*/
PluginManager.prototype.doOperation = function (operation, plugin, options) {
- if (operation !== PluginManager.INSTALL && operation !== PluginManager.UNINSTALL)
- return Q.reject(new CordovaError('The parameter is incorrect. The opeation must be either "add" or "remove"'));
+ if (operation !== PluginManager.INSTALL && operation !== PluginManager.UNINSTALL) { return Q.reject(new CordovaError('The parameter is incorrect. The opeation must be either "add" or "remove"')); }
- if (!plugin || plugin.constructor.name !== 'PluginInfo')
- return Q.reject(new CordovaError('The parameter is incorrect. The first parameter should be a PluginInfo instance'));
+ if (!plugin || plugin.constructor.name !== 'PluginInfo') { return Q.reject(new CordovaError('The parameter is incorrect. The first parameter should be a PluginInfo instance')); }
// Set default to empty object to play safe when accesing properties
options = options || {};
@@ -98,49 +95,49 @@ PluginManager.prototype.doOperation = function (operation, plugin, options) {
plugin.getFilesAndFrameworks(this.platform)
.concat(plugin.getAssets(this.platform))
.concat(plugin.getJsModules(this.platform))
- // ... put them into stack ...
- .forEach(function(item) {
- var installer = self.project.getInstaller(item.itemType);
- var uninstaller = self.project.getUninstaller(item.itemType);
- var actionArgs = [item, plugin, self.project, options];
-
- var action;
- if (operation === PluginManager.INSTALL) {
- action = actions.createAction.apply(actions, [installer, actionArgs, uninstaller, actionArgs]);
- } else /* op === PluginManager.UNINSTALL */{
- action = actions.createAction.apply(actions, [uninstaller, actionArgs, installer, actionArgs]);
- }
- actions.push(action);
- });
+ // ... put them into stack ...
+ .forEach(function (item) {
+ var installer = self.project.getInstaller(item.itemType);
+ var uninstaller = self.project.getUninstaller(item.itemType);
+ var actionArgs = [item, plugin, self.project, options];
+
+ var action;
+ if (operation === PluginManager.INSTALL) {
+ action = actions.createAction.apply(actions, [installer, actionArgs, uninstaller, actionArgs]); /* eslint no-useless-call: 0 */
+ } else /* op === PluginManager.UNINSTALL */{
+ action = actions.createAction.apply(actions, [uninstaller, actionArgs, installer, actionArgs]); /* eslint no-useless-call: 0 */
+ }
+ actions.push(action);
+ });
// ... and run through the action stack
return actions.process(this.platform)
- .then(function () {
- if (self.project.write) {
- self.project.write();
- }
-
- if (operation === PluginManager.INSTALL) {
- // Ignore passed `is_top_level` option since platform itself doesn't know
- // anything about managing dependencies - it's responsibility of caller.
- self.munger.add_plugin_changes(plugin, options.variables, /*is_top_level=*/true, /*should_increment=*/true, options.force);
- self.munger.platformJson.addPluginMetadata(plugin);
- } else {
- self.munger.remove_plugin_changes(plugin, /*is_top_level=*/true);
- self.munger.platformJson.removePluginMetadata(plugin);
- }
-
- // Save everything (munge and plugin/modules metadata)
- self.munger.save_all();
-
- var metadata = self.munger.platformJson.generateMetadata();
- fs.writeFileSync(path.join(self.locations.www, 'cordova_plugins.js'), metadata, 'utf-8');
-
- // CB-11022 save plugin metadata to both www and platform_www if options.usePlatformWww is specified
- if (options.usePlatformWww) {
- fs.writeFileSync(path.join(self.locations.platformWww, 'cordova_plugins.js'), metadata, 'utf-8');
- }
- });
+ .then(function () {
+ if (self.project.write) {
+ self.project.write();
+ }
+
+ if (operation === PluginManager.INSTALL) {
+ // Ignore passed `is_top_level` option since platform itself doesn't know
+ // anything about managing dependencies - it's responsibility of caller.
+ self.munger.add_plugin_changes(plugin, options.variables, /* is_top_level= */true, /* should_increment= */true, options.force);
+ self.munger.platformJson.addPluginMetadata(plugin);
+ } else {
+ self.munger.remove_plugin_changes(plugin, /* is_top_level= */true);
+ self.munger.platformJson.removePluginMetadata(plugin);
+ }
+
+ // Save everything (munge and plugin/modules metadata)
+ self.munger.save_all();
+
+ var metadata = self.munger.platformJson.generateMetadata();
+ fs.writeFileSync(path.join(self.locations.www, 'cordova_plugins.js'), metadata, 'utf-8');
+
+ // CB-11022 save plugin metadata to both www and platform_www if options.usePlatformWww is specified
+ if (options.usePlatformWww) {
+ fs.writeFileSync(path.join(self.locations.platformWww, 'cordova_plugins.js'), metadata, 'utf-8');
+ }
+ });
};
PluginManager.prototype.addPlugin = function (plugin, installOptions) {
http://git-wip-us.apache.org/repos/asf/cordova-common/blob/54450166/src/events.js
----------------------------------------------------------------------
diff --git a/src/events.js b/src/events.js
index 3080416..7038643 100644
--- a/src/events.js
+++ b/src/events.js
@@ -40,8 +40,7 @@ module.exports.forwardEventsTo = function (eventEmitter) {
return;
}
- if (!(eventEmitter instanceof EventEmitter))
- throw new Error('Cordova events can be redirected to another EventEmitter instance only');
+ if (!(eventEmitter instanceof EventEmitter)) { throw new Error('Cordova events can be redirected to another EventEmitter instance only'); }
// CB-10940 Skipping forwarding to self to avoid infinite recursion.
// This is the case when the modules are npm-linked.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org