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:54 UTC
[3/4] cordova-common git commit: CB-12895 : set up eslint and removed
jshint
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