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/28 18:26:33 UTC
[02/18] cordova-lib git commit: CB-12895 : ran eslint --fix on
cordova-lib
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/plugman/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/plugman/util/plugins.js b/src/plugman/util/plugins.js
index b3cef6a..72409ee 100644
--- a/src/plugman/util/plugins.js
+++ b/src/plugman/util/plugins.js
@@ -17,20 +17,20 @@
under the License.
*/
-var path = require('path'),
- shell = require('shelljs'),
- events = require('cordova-common').events,
- gitclone = require('../../gitclone'),
- tmp_dir;
+var path = require('path');
+var shell = require('shelljs');
+var events = require('cordova-common').events;
+var gitclone = require('../../gitclone');
+var tmp_dir;
var PluginInfo = require('cordova-common').PluginInfo;
module.exports = {
- searchAndReplace:require('./search-and-replace'),
+ searchAndReplace: require('./search-and-replace'),
- clonePluginGit:function(plugin_git_url, plugins_dir, options) {
+ clonePluginGit: function (plugin_git_url, plugins_dir, options) {
return module.exports.clonePluginGitRepo(plugin_git_url, plugins_dir, options.subdir, options.git_ref, options.pluginInfoProvider).then(
- function(dst){
+ function (dst) {
// Keep location where we checked out git repo
options.plugin_src_dir = tmp_dir;
return dst;
@@ -38,8 +38,8 @@ module.exports = {
);
},
- clonePluginGitRepo:function(plugin_git_url, plugins_dir, subdir, git_ref, pluginInfoProvider) {
- return gitclone.clone(plugin_git_url, git_ref).then(function(tmp_dir) {
+ clonePluginGitRepo: function (plugin_git_url, plugins_dir, subdir, git_ref, pluginInfoProvider) {
+ return gitclone.clone(plugin_git_url, git_ref).then(function (tmp_dir) {
// Read the plugin.xml file and extract the plugin's ID.
tmp_dir = path.join(tmp_dir, subdir);
var pluginInfo = new PluginInfo(tmp_dir);
@@ -69,4 +69,3 @@ module.exports = {
});
}
};
-
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/plugman/util/search-and-replace.js
----------------------------------------------------------------------
diff --git a/src/plugman/util/search-and-replace.js b/src/plugman/util/search-and-replace.js
index e84f7a0..a27dc05 100644
--- a/src/plugman/util/search-and-replace.js
+++ b/src/plugman/util/search-and-replace.js
@@ -1,5 +1,5 @@
#!/usr/bin/env node
- /**
+/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
@@ -16,13 +16,13 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-*/
+*/
-var glob = require('glob'),
- fs = require('fs');
+var glob = require('glob');
+var fs = require('fs');
module.exports = searchAndReplace;
-function searchAndReplace(srcGlob, variables) {
+function searchAndReplace (srcGlob, variables) {
var files = glob.sync(srcGlob);
for (var i in files) {
var file = files[i];
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/plugman/util/strip-license.js
----------------------------------------------------------------------
diff --git a/src/plugman/util/strip-license.js b/src/plugman/util/strip-license.js
index c2948d0..5df03bf 100644
--- a/src/plugman/util/strip-license.js
+++ b/src/plugman/util/strip-license.js
@@ -20,6 +20,6 @@
module.exports = {
fromCode: function (code) {
// For simplicity, relies on the fact that the Apache license header doesn't contain a "*"
- return code.replace(/^\s*\/\*\*[^\*]*\*\/\s*/, "");
+ return code.replace(/^\s*\/\*\*[^\*]*\*\/\s*/, ''); // eslint-disable-line no-useless-escape
}
};
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/util/alias.js
----------------------------------------------------------------------
diff --git a/src/util/alias.js b/src/util/alias.js
index c4a51f3..9b9a702 100644
--- a/src/util/alias.js
+++ b/src/util/alias.js
@@ -19,8 +19,8 @@
var cordova_events = require('cordova-common').events;
-module.exports = function aliasMethodToRawWithDeprecationNotice(property, targetObj, component) {
- targetObj.raw[property] = function() {
+module.exports = function aliasMethodToRawWithDeprecationNotice (property, targetObj, component) {
+ targetObj.raw[property] = function () {
cordova_events.emit('warn', 'Use of ' + component + '.raw.* methods is deprecated and ' + component + '.raw will be removed in a future release. Please migrate to using the top-level ' + component + '.* methods instead.');
return targetObj[property].apply(targetObj, arguments);
};
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/util/npm-helper.js
----------------------------------------------------------------------
diff --git a/src/util/npm-helper.js b/src/util/npm-helper.js
index e1e5322..f8003c1 100644
--- a/src/util/npm-helper.js
+++ b/src/util/npm-helper.js
@@ -19,14 +19,14 @@
// Helper methods to help keep npm operations separated.
-var npm = require('npm'),
- path = require('path'),
- fs = require('fs'),
- Q = require('q'),
- unpack = require('./unpack'),
- util = require('../cordova/util'),
- cachedSettings = null,
- cachedSettingsValues = null;
+var npm = require('npm');
+var path = require('path');
+var fs = require('fs');
+var Q = require('q');
+var unpack = require('./unpack');
+var util = require('../cordova/util');
+var cachedSettings = null;
+var cachedSettingsValues = null;
/**
* @description Calls npm.load, then initializes npm.config with the specified settings. Then executes a chain of
@@ -35,11 +35,11 @@ var npm = require('npm'),
* @param {Object} settings
* @param {Function} promiseChain
*/
-function loadWithSettingsThenRestore(settings, promiseChain) {
+function loadWithSettingsThenRestore (settings, promiseChain) {
return loadWithSettings(settings).then(promiseChain).finally(restoreSettings);
}
-function loadWithSettings(settings) {
+function loadWithSettings (settings) {
if (cachedSettings) {
throw new Error('Trying to initialize npm when settings have not been restored from a previous initialization.');
}
@@ -62,7 +62,7 @@ function loadWithSettings(settings) {
});
}
-function restoreSettings() {
+function restoreSettings () {
if (cachedSettings) {
cachedSettings.forEach(function (prop) {
if (prop in cachedSettingsValues) {
@@ -82,7 +82,7 @@ function restoreSettings() {
* @param packageName - name of an npm package
* @param packageVersion - requested version or version range
*/
-function fetchPackage(packageName, packageVersion) {
+function fetchPackage (packageName, packageVersion) {
// Get the latest matching version from NPM if a version range is specified
return util.getLatestMatchingNpmVersion(packageName, packageVersion).then(
function (latestVersion) {
@@ -97,7 +97,7 @@ function fetchPackage(packageName, packageVersion) {
* @param packageName - name of an npm package
* @param packageVersion - requested version (not a version range)
*/
-function cachePackage(packageName, packageVersion) {
+function cachePackage (packageName, packageVersion) {
return Q().then(function () {
var cacheDir = path.join(util.libDirectory, 'npm_cache');
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/util/promise-util.js
----------------------------------------------------------------------
diff --git a/src/util/promise-util.js b/src/util/promise-util.js
index 4d21050..df1081d 100644
--- a/src/util/promise-util.js
+++ b/src/util/promise-util.js
@@ -23,10 +23,10 @@ var Q = require('q');
// will sequentially execute func(args[i]).
// Returns a promise.
//
-function Q_chainmap(args, func) {
- return Q.when().then(function(inValue) {
- return args.reduce(function(soFar, arg) {
- return soFar.then(function(val) {
+function Q_chainmap (args, func) {
+ return Q.when().then(function (inValue) {
+ return args.reduce(function (soFar, arg) {
+ return soFar.then(function (val) {
return func(arg, val);
});
}, Q(inValue));
@@ -35,12 +35,12 @@ function Q_chainmap(args, func) {
// Behaves similar to Q_chainmap but gracefully handles failures.
// When a promise in the chain is rejected, it will call the failureCallback and then continue the processing, instead of stopping
-function Q_chainmap_graceful(args, func, failureCallback) {
- return Q.when().then(function(inValue) {
- return args.reduce(function(soFar, arg) {
- return soFar.then(function(val) {
+function Q_chainmap_graceful (args, func, failureCallback) {
+ return Q.when().then(function (inValue) {
+ return args.reduce(function (soFar, arg) {
+ return soFar.then(function (val) {
return func(arg, val);
- }).fail(function(err) {
+ }).fail(function (err) {
if (failureCallback) {
failureCallback(err);
}
@@ -50,4 +50,4 @@ function Q_chainmap_graceful(args, func, failureCallback) {
}
exports.Q_chainmap = Q_chainmap;
-exports.Q_chainmap_graceful = Q_chainmap_graceful;
\ No newline at end of file
+exports.Q_chainmap_graceful = Q_chainmap_graceful;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/util/unpack.js
----------------------------------------------------------------------
diff --git a/src/util/unpack.js b/src/util/unpack.js
index f0ec451..6997fef 100644
--- a/src/util/unpack.js
+++ b/src/util/unpack.js
@@ -20,37 +20,36 @@
// commands for packing and unpacking tarballs
// this file is used by lib/cache.js
-var events = require('cordova-common').events,
- fs = require('fs'),
- Q = require('q'),
- tar = require('tar'),
- zlib = require('zlib');
+var events = require('cordova-common').events;
+var fs = require('fs');
+var Q = require('q');
+var tar = require('tar');
+var zlib = require('zlib');
exports.unpackTgz = unpackTgz;
// Returns a promise for the path to the unpacked tarball (unzip + untar).
-function unpackTgz(package_tgz, unpackTarget) {
- return Q.promise(function(resolve, reject) {
+function unpackTgz (package_tgz, unpackTarget) {
+ return Q.promise(function (resolve, reject) {
var extractOpts = { type: 'Directory', path: unpackTarget, strip: 1 };
fs.createReadStream(package_tgz)
- .on('error', function (err) {
- events.emit('warn', 'Unable to open tarball ' + package_tgz + ': ' + err);
- reject(err);
- })
- .pipe(zlib.createUnzip())
- .on('error', function (err) {
- events.emit('warn', 'Error during unzip for ' + package_tgz + ': ' + err);
- reject(err);
- })
- .pipe(tar.Extract(extractOpts))
- .on('error', function(err) {
- events.emit('warn', 'Error during untar for ' + package_tgz + ': ' + err);
- reject(err);
- })
- .on('end', resolve);
- })
- .then(function() {
+ .on('error', function (err) {
+ events.emit('warn', 'Unable to open tarball ' + package_tgz + ': ' + err);
+ reject(err);
+ })
+ .pipe(zlib.createUnzip())
+ .on('error', function (err) {
+ events.emit('warn', 'Error during unzip for ' + package_tgz + ': ' + err);
+ reject(err);
+ })
+ .pipe(tar.Extract(extractOpts))
+ .on('error', function (err) {
+ events.emit('warn', 'Error during untar for ' + package_tgz + ': ' + err);
+ reject(err);
+ })
+ .on('end', resolve);
+ }).then(function () {
return unpackTarget;
});
}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/util/windows/csproj.js
----------------------------------------------------------------------
diff --git a/src/util/windows/csproj.js b/src/util/windows/csproj.js
index 092fba9..51efb5f 100644
--- a/src/util/windows/csproj.js
+++ b/src/util/windows/csproj.js
@@ -17,25 +17,25 @@
under the License.
*/
-var xml_helpers = require('cordova-common').xmlHelpers,
- et = require('elementtree'),
- fs = require('fs'),
- path = require('path');
+var xml_helpers = require('cordova-common').xmlHelpers;
+var et = require('elementtree');
+var fs = require('fs');
+var path = require('path');
-function csproj(location) {
+function csproj (location) {
this.location = location;
this.xml = xml_helpers.parseElementtreeSync(location);
return this;
}
csproj.prototype = {
- write:function() {
- fs.writeFileSync(this.location, this.xml.write({indent:4}), 'utf-8');
+ write: function () {
+ fs.writeFileSync(this.location, this.xml.write({indent: 4}), 'utf-8');
},
// add/remove the item group for SDKReference
// example :
// <ItemGroup><SDKReference Include="MSAdvertising, Version=6.1" /></ItemGroup>
- addSDKRef:function(incText) {
+ addSDKRef: function (incText) {
var item_group = new et.Element('ItemGroup');
var elem = new et.Element('SDKReference');
elem.attrib.Include = incText;
@@ -44,13 +44,13 @@ csproj.prototype = {
this.xml.getroot().append(item_group);
},
- removeSDKRef:function(incText) {
+ removeSDKRef: function (incText) {
var item_group = this.xml.find('ItemGroup/SDKReference[@Include="' + incText + '"]/..');
- if(item_group) {
+ if (item_group) {
this.xml.getroot().remove(item_group);
}
},
- addReference:function(relPath) {
+ addReference: function (relPath) {
var item = new et.Element('ItemGroup');
var extName = path.extname(relPath);
@@ -62,7 +62,7 @@ csproj.prototype = {
hint_path.text = relPath;
elem.append(hint_path);
- if(extName == '.winmd') {
+ if (extName === '.winmd') {
var mdFileTag = new et.Element('IsWinMDFile');
mdFileTag.text = 'true';
elem.append(mdFileTag);
@@ -73,19 +73,19 @@ csproj.prototype = {
this.xml.getroot().append(item);
},
- removeReference:function(relPath) {
+ removeReference: function (relPath) {
var extName = path.extname(relPath);
- var includeText = path.basename(relPath,extName);
+ var includeText = path.basename(relPath, extName);
// <ItemGroup>
// <Reference Include="WindowsRuntimeComponent1">
var item_groups = this.xml.findall('ItemGroup/Reference[@Include="' + includeText + '"]/..');
- if(item_groups.length > 0 ) {
+ if (item_groups.length > 0) {
this.xml.getroot().remove(item_groups[0]);
}
},
- addSourceFile:function(relative_path) {
+ addSourceFile: function (relative_path) {
// we allow multiple paths to be passed at once as array so that
// we don't create separate ItemGroup for each source file, CB-6874
if (!(relative_path instanceof Array)) {
@@ -95,12 +95,12 @@ csproj.prototype = {
// make ItemGroup to hold file.
var item = new et.Element('ItemGroup');
var me = this;
- relative_path.forEach(function(filePath) {
+ relative_path.forEach(function (filePath) {
filePath = filePath.split('/').join('\\');
var extName = path.extname(filePath);
// check if it's a .xaml page
- if(extName == '.xaml') {
+ if (extName === '.xaml') {
var page = new et.Element('Page');
var sub_type = new et.Element('SubType');
@@ -112,14 +112,13 @@ csproj.prototype = {
gen.text = 'MSBuild:Compile';
page.append(gen);
var item_groups = me.xml.findall('ItemGroup');
- if(item_groups.length === 0) {
+ if (item_groups.length === 0) {
item.append(page);
} else {
item_groups[0].append(page);
}
- }
- else if (extName == '.cs') {
+ } else if (extName === '.cs') {
compile = new et.Element('Compile');
compile.attrib.Include = filePath;
// check if it's a .xaml.cs page that would depend on a .xaml of the same name
@@ -131,8 +130,7 @@ csproj.prototype = {
compile.append(dep);
}
item.append(compile);
- }
- else { // otherwise add it normally
+ } else { // otherwise add it normally
compile = new et.Element('Content');
compile.attrib.Include = filePath;
item.append(compile);
@@ -141,7 +139,7 @@ csproj.prototype = {
this.xml.getroot().append(item);
},
- removeSourceFile:function(relative_path) {
+ removeSourceFile: function (relative_path) {
var isRegexp = relative_path instanceof RegExp;
if (!isRegexp) {
@@ -151,25 +149,25 @@ csproj.prototype = {
var root = this.xml.getroot();
// iterate through all ItemGroup/Content elements and remove all items matched
- this.xml.findall('ItemGroup').forEach(function(group){
+ this.xml.findall('ItemGroup').forEach(function (group) {
// matched files in current ItemGroup
var filesToRemove = group.findall('Compile').concat(group.findall('Page'))
- .concat(group.findall('Content')).filter(function(item) {
+ .concat(group.findall('Content')).filter(function (item) {
if (!item.attrib.Include) return false;
return isRegexp ? item.attrib.Include.match(relative_path) :
- item.attrib.Include == relative_path;
+ item.attrib.Include === relative_path;
});
// nothing to remove, skip..
if (filesToRemove.length < 1) return;
- filesToRemove.forEach(function(file){
+ filesToRemove.forEach(function (file) {
// remove file reference
group.remove(file);
});
// remove ItemGroup if empty
- if(group.findall('*').length < 1) {
+ if (group.findall('*').length < 1) {
root.remove(group);
}
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/src/util/windows/jsprojManager.js
----------------------------------------------------------------------
diff --git a/src/util/windows/jsprojManager.js b/src/util/windows/jsprojManager.js
index 163ac42..c0aec68 100644
--- a/src/util/windows/jsprojManager.js
+++ b/src/util/windows/jsprojManager.js
@@ -17,25 +17,24 @@
under the License.
*/
-/* jshint quotmark:false, unused:false */
-
/*
Helper for dealing with Windows Store JS app .jsproj files
*/
+var util = require('util');
+var xml_helpers = require('cordova-common').xmlHelpers;
+var et = require('elementtree');
+var fs = require('fs');
+var glob = require('glob');
+var shell = require('shelljs');
+var events = require('cordova-common').events;
+var path = require('path');
+var semver = require('semver');
-var util = require('util'),
- xml_helpers = require('cordova-common').xmlHelpers,
- et = require('elementtree'),
- fs = require('fs'),
- glob = require('glob'),
- shell = require('shelljs'),
- events = require('cordova-common').events,
- path = require('path'),
- semver = require('semver');
+var WinCSharpProjectTypeGUID = '{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}'; // .csproj
+var WinCplusplusProjectTypeGUID = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}'; // .vcxproj
-var WinCSharpProjectTypeGUID = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"; // .csproj
-var WinCplusplusProjectTypeGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; // .vcxproj
+/* eslint-disable no-useless-escape */
// Match a JavaScript Project
var JsProjectRegEx = /(Project\("\{262852C6-CD72-467D-83FE-5EEB1973A190}"\)\s*=\s*"[^"]+",\s*"[^"]+",\s*"\{[0-9a-f\-]+}"[^\r\n]*[\r\n]*)/gi;
@@ -43,17 +42,18 @@ var JsProjectRegEx = /(Project\("\{262852C6-CD72-467D-83FE-5EEB1973A190}"\)\s*=\
// Chars in a string that need to be escaped when used in a RegExp
var RegExpEscRegExp = /([.?*+\^$\[\]\\(){}|\-])/g;
-function jsprojManager(location) {
- this.isUniversalWindowsApp = path.extname(location).toLowerCase() === ".projitems";
+function jsprojManager (location) {
+ this.isUniversalWindowsApp = path.extname(location).toLowerCase() === '.projitems';
this.projects = [];
- this.master = this.isUniversalWindowsApp ? new proj(location) : new jsproj(location);
+ this.master = this.isUniversalWindowsApp ? new proj(location) : new jsproj(location); // eslint-disable-line new-cap
this.projectFolder = path.dirname(location);
}
+/* eslint-enable no-useless-escape */
-function getProjectName(pluginProjectXML, relative_path) {
- var projNameElt = pluginProjectXML.find("PropertyGroup/ProjectName");
+function getProjectName (pluginProjectXML, relative_path) {
+ var projNameElt = pluginProjectXML.find('PropertyGroup/ProjectName');
// Falling back on project file name in case ProjectName is missing
- return !!projNameElt ? projNameElt.text : path.basename(relative_path, path.extname(relative_path));
+ return projNameElt ? projNameElt.text : path.basename(relative_path, path.extname(relative_path));
}
jsprojManager.prototype = {
@@ -123,9 +123,9 @@ jsprojManager.prototype = {
var children = [hint_path];
var extName = path.extname(relPath);
- if (extName === ".winmd") {
- var mdFileTag = new et.Element("IsWinMDFile");
- mdFileTag.text = "true";
+ if (extName === '.winmd') {
+ var mdFileTag = new et.Element('IsWinMDFile');
+ mdFileTag.text = 'true';
children.push(mdFileTag);
}
@@ -168,18 +168,18 @@ jsprojManager.prototype = {
var pluginProjectXML = xml_helpers.parseElementtreeSync(relative_path);
// find the guid + name of the referenced project
- var projectGuid = pluginProjectXML.find("PropertyGroup/ProjectGuid").text;
+ var projectGuid = pluginProjectXML.find('PropertyGroup/ProjectGuid').text;
var projName = getProjectName(pluginProjectXML, relative_path);
// get the project type
var projectTypeGuid = getProjectTypeGuid(relative_path);
if (!projectTypeGuid) {
- throw new Error("unrecognized project type");
+ throw new Error('unrecognized project type');
}
- var preInsertText = "\tProjectSection(ProjectDependencies) = postProject\r\n" +
- "\t\t" + projectGuid + "=" + projectGuid + "\r\n" +
- "\tEndProjectSection\r\n";
+ var preInsertText = '\tProjectSection(ProjectDependencies) = postProject\r\n' +
+ '\t\t' + projectGuid + '=' + projectGuid + '\r\n' +
+ '\tEndProjectSection\r\n';
var postInsertText = '\r\nProject("' + projectTypeGuid + '") = "' +
projName + '", "' + inserted_path + '", ' +
'"' + projectGuid + '"\r\nEndProject';
@@ -195,7 +195,7 @@ jsprojManager.prototype = {
// There may be multiple solution files (for different VS versions) - process them all
getSolutionPaths(this.projectFolder).forEach(function (solutionPath) {
- var solText = fs.readFileSync(solutionPath, {encoding: "utf8"});
+ var solText = fs.readFileSync(solutionPath, {encoding: 'utf8'});
if (useProjItems) {
// Insert a project dependency into every jsproj in the solution.
@@ -206,7 +206,7 @@ jsprojManager.prototype = {
});
if (!jsProjectFound) {
- throw new Error("no jsproj found in solution");
+ throw new Error('no jsproj found in solution');
}
} else {
// Insert a project dependency only for projects that match specified target and version
@@ -219,14 +219,14 @@ jsprojManager.prototype = {
// Add the project after existing projects. Note that this fairly simplistic check should be fine, since the last
// EndProject in the file should actually be an EndProject (and not an EndProjectSection, for example).
- var pos = solText.lastIndexOf("EndProject");
+ var pos = solText.lastIndexOf('EndProject');
if (pos === -1) {
- throw new Error("no EndProject found in solution");
+ throw new Error('no EndProject found in solution');
}
pos += 10; // Move pos to the end of EndProject text
solText = solText.slice(0, pos) + postInsertText + solText.slice(pos);
- fs.writeFileSync(solutionPath, solText, {encoding: "utf8"});
+ fs.writeFileSync(solutionPath, solText, {encoding: 'utf8'});
});
// Add the ItemGroup/ProjectReference to each matching cordova project :
@@ -247,13 +247,13 @@ jsprojManager.prototype = {
// find the guid + name of the referenced project
var pluginProjectXML = xml_helpers.parseElementtreeSync(relative_path);
- var projectGuid = pluginProjectXML.find("PropertyGroup/ProjectGuid").text;
+ var projectGuid = pluginProjectXML.find('PropertyGroup/ProjectGuid').text;
var projName = getProjectName(pluginProjectXML, relative_path);
// get the project type
var projectTypeGuid = getProjectTypeGuid(relative_path);
if (!projectTypeGuid) {
- throw new Error("unrecognized project type");
+ throw new Error('unrecognized project type');
}
var preInsertTextRegExp = getProjectReferencePreInsertRegExp(projectGuid);
@@ -261,20 +261,20 @@ jsprojManager.prototype = {
// There may be multiple solutions (for different VS versions) - process them all
getSolutionPaths(this.projectFolder).forEach(function (solutionPath) {
- var solText = fs.readFileSync(solutionPath, {encoding: "utf8"});
+ var solText = fs.readFileSync(solutionPath, {encoding: 'utf8'});
// To be safe (to handle subtle changes in formatting, for example), use a RegExp to find and remove
// preInsertText and postInsertText
solText = solText.replace(preInsertTextRegExp, function () {
- return "";
+ return '';
});
solText = solText.replace(postInsertTextRegExp, function () {
- return "";
+ return '';
});
- fs.writeFileSync(solutionPath, solText, {encoding: "utf8"});
+ fs.writeFileSync(solutionPath, solText, {encoding: 'utf8'});
});
this._getMatchingProjects(targetConditions).forEach(function (project) {
@@ -304,7 +304,7 @@ jsprojManager.prototype = {
return [this.master];
},
- get projects() {
+ get projects () {
var projects = this._projects;
if (!projects) {
projects = [];
@@ -314,7 +314,7 @@ jsprojManager.prototype = {
var projectPath = this.projectFolder;
var projectFiles = glob.sync('*.jsproj', {cwd: projectPath});
projectFiles.forEach(function (projectFile) {
- projects.push(new jsproj(path.join(projectPath, projectFile)));
+ projects.push(new jsproj(path.join(projectPath, projectFile))); // eslint-disable-line new-cap
});
} else {
this.projects.push(this.master);
@@ -325,12 +325,12 @@ jsprojManager.prototype = {
}
};
-function getProjectReferencePreInsertRegExp(projectGuid) {
+function getProjectReferencePreInsertRegExp (projectGuid) {
projectGuid = escapeRegExpString(projectGuid);
- return new RegExp("\\s*ProjectSection\\(ProjectDependencies\\)\\s*=\\s*postProject\\s*" + projectGuid + "\\s*=\\s*" + projectGuid + "\\s*EndProjectSection", "gi");
+ return new RegExp('\\s*ProjectSection\\(ProjectDependencies\\)\\s*=\\s*postProject\\s*' + projectGuid + '\\s*=\\s*' + projectGuid + '\\s*EndProjectSection', 'gi');
}
-function getProjectReferencePostInsertRegExp(projName, projectGuid, relative_path, projectTypeGuid) {
+function getProjectReferencePostInsertRegExp (projName, projectGuid, relative_path, projectTypeGuid) {
projName = escapeRegExpString(projName);
projectGuid = escapeRegExpString(projectGuid);
relative_path = escapeRegExpString(relative_path);
@@ -338,31 +338,31 @@ function getProjectReferencePostInsertRegExp(projName, projectGuid, relative_pat
return new RegExp('\\s*Project\\("' + projectTypeGuid + '"\\)\\s*=\\s*"' + projName + '"\\s*,\\s*"' + relative_path + '"\\s*,\\s*"' + projectGuid + '"\\s*EndProject', 'gi');
}
-function getSolutionPaths(projectFolder) {
- return shell.ls(path.join(projectFolder, "*.sln")); // TODO:error handling
+function getSolutionPaths (projectFolder) {
+ return shell.ls(path.join(projectFolder, '*.sln')); // TODO:error handling
}
-function escapeRegExpString(regExpString) {
- return regExpString.replace(RegExpEscRegExp, "\\$1");
+function escapeRegExpString (regExpString) {
+ return regExpString.replace(RegExpEscRegExp, '\\$1');
}
-function getJsProjRegExForProject(projectFile) {
+function getJsProjRegExForProject (projectFile) {
projectFile = escapeRegExpString(projectFile);
return new RegExp('(Project\\("\\{262852C6-CD72-467D-83FE-5EEB1973A190}"\\)\\s*=\\s*"[^"]+",\\s*"' + projectFile + '",\\s*"\\{[0-9a-f\\-]+}"[^\\r\\n]*[\\r\\n]*)', 'gi');
}
-function getProjectTypeGuid(projectPath) {
+function getProjectTypeGuid (projectPath) {
switch (path.extname(projectPath)) {
- case ".vcxproj":
- return WinCplusplusProjectTypeGUID;
+ case '.vcxproj':
+ return WinCplusplusProjectTypeGUID;
- case ".csproj":
- return WinCSharpProjectTypeGUID;
+ case '.csproj':
+ return WinCSharpProjectTypeGUID;
}
return null;
}
-function createItemGroupElement(path, incText, targetConditions, children) {
+function createItemGroupElement (path, incText, targetConditions, children) {
path = path.split('/');
path.reverse();
@@ -391,15 +391,15 @@ function createItemGroupElement(path, incText, targetConditions, children) {
return lastElement;
}
-function getDeviceTarget(targetConditions) {
+function getDeviceTarget (targetConditions) {
var target = targetConditions.deviceTarget;
if (target) {
target = target.toLowerCase().trim();
- if (target === "all") {
+ if (target === 'all') {
target = null;
- } else if (target === "win") {
+ } else if (target === 'win') {
// Allow "win" as alternative to "windows"
- target = "windows";
+ target = 'windows';
} else if (target !== 'phone' && target !== 'windows') {
throw new Error('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): ' + target);
}
@@ -407,7 +407,7 @@ function getDeviceTarget(targetConditions) {
return target;
}
-function getVersions(targetConditions) {
+function getVersions (targetConditions) {
var versions = targetConditions.versions;
if (versions && !semver.validRange(versions, /* loose */ true)) {
throw new Error('Invalid versions attribute (must be a valid semantic version range): ' + versions);
@@ -415,10 +415,9 @@ function getVersions(targetConditions) {
return versions;
}
-
/* proj */
-function proj(location) {
+function proj (location) {
// Class to handle simple project xml operations
if (!location) {
throw new Error('Project file location can\'t be null or empty');
@@ -513,24 +512,23 @@ proj.prototype = {
}
};
-
/* jsproj */
-function jsproj(location) {
- function targetPlatformIdentifierToDevice(jsprojPlatform) {
- var index = ["Windows", "WindowsPhoneApp", "UAP"].indexOf(jsprojPlatform);
+function jsproj (location) {
+ function targetPlatformIdentifierToDevice (jsprojPlatform) {
+ var index = ['Windows', 'WindowsPhoneApp', 'UAP'].indexOf(jsprojPlatform);
if (index < 0) {
throw new Error("Unknown TargetPlatformIdentifier '" + jsprojPlatform + "' in project file '" + location + "'");
}
- return ["windows", "phone", "windows"][index];
+ return ['windows', 'phone', 'windows'][index];
}
- function validateVersion(version) {
+ function validateVersion (version) {
version = version.split('.');
while (version.length < 3) {
- version.push("0");
+ version.push('0');
}
- return version.join(".");
+ return version.join('.');
}
// Class to handle a jsproj file
@@ -566,20 +564,20 @@ jsproj.prototype.getSemVersion = function () {
}
return semVersion;
- // Alternative approach could be replacing last dot with plus sign to
- // be complaint w/ semver specification, for example
- // 10.0.10240.0 -> 10.0.10240+0
+ // Alternative approach could be replacing last dot with plus sign to
+ // be complaint w/ semver specification, for example
+ // 10.0.10240.0 -> 10.0.10240+0
};
/* Common support functions */
-function createConditionAttrib(targetConditions) {
+function createConditionAttrib (targetConditions) {
var arch = targetConditions.arch;
if (arch) {
- if (arch === "arm") {
+ if (arch === 'arm') {
// Specifcally allow "arm" as alternative to "ARM"
- arch = "ARM";
- } else if (arch !== "x86" && arch !== "x64" && arch !== "ARM") {
+ arch = 'ARM';
+ } else if (arch !== 'x86' && arch !== 'x64' && arch !== 'ARM') {
throw new Error('Invalid arch attribute (must be "x86", "x64" or "ARM"): ' + arch);
}
return "'$(Platform)'=='" + arch + "'";
@@ -587,5 +585,4 @@ function createConditionAttrib(targetConditions) {
return null;
}
-
module.exports = jsprojManager;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/17438d2b/templates/base.js
----------------------------------------------------------------------
diff --git a/templates/base.js b/templates/base.js
index b517b39..c89ca45 100644
--- a/templates/base.js
+++ b/templates/base.js
@@ -19,6 +19,6 @@
var exec = require('cordova/exec');
-exports.coolMethod = function(arg0, success, error) {
- exec(success, error, "%pluginName%", "coolMethod", [arg0]);
+exports.coolMethod = function (arg0, success, error) {
+ exec(success, error, '%pluginName%', 'coolMethod', [arg0]);
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org