diff options
Diffstat (limited to 'StoneIsland/platforms/ios/cordova/lib/Podfile.js')
| -rwxr-xr-x | StoneIsland/platforms/ios/cordova/lib/Podfile.js | 139 |
1 files changed, 77 insertions, 62 deletions
diff --git a/StoneIsland/platforms/ios/cordova/lib/Podfile.js b/StoneIsland/platforms/ios/cordova/lib/Podfile.js index 084c10c3..49173c4c 100755 --- a/StoneIsland/platforms/ios/cordova/lib/Podfile.js +++ b/StoneIsland/platforms/ios/cordova/lib/Podfile.js @@ -16,18 +16,19 @@ specific language governing permissions and limitations under the License. */ +'use strict'; -var fs = require('fs'), - path = require('path'), - util = require('util'), - events = require('cordova-common').events, - Q = require('q'), - superspawn = require('cordova-common').superspawn, - CordovaError = require('cordova-common').CordovaError; +var fs = require('fs'); +var path = require('path'); +var util = require('util'); +var events = require('cordova-common').events; +var Q = require('q'); +var superspawn = require('cordova-common').superspawn; +var CordovaError = require('cordova-common').CordovaError; Podfile.FILENAME = 'Podfile'; -function Podfile(podFilePath, projectName) { +function Podfile (podFilePath, projectName) { this.podToken = '##INSERT_POD##'; this.path = podFilePath; @@ -53,12 +54,12 @@ function Podfile(podFilePath, projectName) { this.write(); } else { events.emit('verbose', 'Podfile found in platforms/ios'); - // parse for pods + // parse for pods this.pods = this.__parseForPods(fs.readFileSync(this.path, 'utf8')); } } -Podfile.prototype.__parseForPods = function(text) { +Podfile.prototype.__parseForPods = function (text) { // split by \n var arr = text.split('\n'); @@ -69,38 +70,45 @@ Podfile.prototype.__parseForPods = function(text) { var podRE = new RegExp('pod \'([^\']*)\'\\s*,?\\s*(.*)'); // only grab lines that don't have the pod spec' - return arr.filter(function(line) { + return arr.filter(function (line) { var m = podRE.exec(line); return (m !== null); }) - .reduce(function(obj, line){ - var m = podRE.exec(line); + .reduce(function (obj, line) { + var m = podRE.exec(line); - if (m !== null) { - // strip out any single quotes around the value m[2] - var podSpec = m[2].replace(/^\'|\'$/g, ''); - obj[m[1]] = podSpec; // i.e pod 'Foo', '1.2' ==> { 'Foo' : '1.2'} - } + if (m !== null) { + // strip out any single quotes around the value m[2] + var podSpec = m[2].replace(/^\'|\'$/g, ''); /* eslint no-useless-escape : 0 */ + obj[m[1]] = podSpec; // i.e pod 'Foo', '1.2' ==> { 'Foo' : '1.2'} + } - return obj; - }, {}); + return obj; + }, {}); }; -Podfile.prototype.getTemplate = function() { +Podfile.prototype.escapeSingleQuotes = function (string) { + return string.replace('\'', '\\\''); +}; + +Podfile.prototype.getTemplate = function () { + // Escaping possible ' in the project name + var projectName = this.escapeSingleQuotes(this.projectName); return util.format( - '# DO NOT MODIFY -- auto-generated by Apache Cordova\n' + + '# DO NOT MODIFY -- auto-generated by Apache Cordova\n' + 'platform :ios, \'8.0\'\n' + 'target \'%s\' do\n' + '\tproject \'%s.xcodeproj\'\n' + '%s\n' + 'end\n', - this.projectName, this.projectName, this.podToken); + projectName, projectName, this.podToken); }; -Podfile.prototype.addSpec = function(name, spec) { +Podfile.prototype.addSpec = function (name, spec) { name = name || ''; - spec = spec; // optional + // optional + spec = spec; /* eslint no-self-assign : 0 */ if (!name.length) { // blank names are not allowed throw new CordovaError('Podfile addSpec: name is not specified.'); @@ -112,39 +120,39 @@ Podfile.prototype.addSpec = function(name, spec) { events.emit('verbose', util.format('Added pod line for `%s`', name)); }; -Podfile.prototype.removeSpec = function(name) { +Podfile.prototype.removeSpec = function (name) { if (this.existsSpec(name)) { delete this.pods[name]; this.__dirty = true; } - + events.emit('verbose', util.format('Removed pod line for `%s`', name)); }; -Podfile.prototype.getSpec = function(name) { +Podfile.prototype.getSpec = function (name) { return this.pods[name]; }; -Podfile.prototype.existsSpec = function(name) { +Podfile.prototype.existsSpec = function (name) { return (name in this.pods); }; -Podfile.prototype.clear = function() { +Podfile.prototype.clear = function () { this.pods = {}; this.__dirty = true; }; -Podfile.prototype.destroy = function() { +Podfile.prototype.destroy = function () { fs.unlinkSync(this.path); events.emit('verbose', util.format('Deleted `%s`', this.path)); }; -Podfile.prototype.write = function() { +Podfile.prototype.write = function () { var text = this.getTemplate(); var self = this; var podsString = - Object.keys(this.pods).map(function(key) { + Object.keys(this.pods).map(function (key) { var name = key; var spec = self.pods[key]; @@ -159,8 +167,7 @@ Podfile.prototype.write = function() { } else { return util.format('\tpod \'%s\'', name); } - }) - .join('\n'); + }).join('\n'); text = text.replace(this.podToken, podsString); fs.writeFileSync(this.path, text, 'utf8'); @@ -169,14 +176,16 @@ Podfile.prototype.write = function() { events.emit('verbose', 'Wrote to Podfile.'); }; -Podfile.prototype.isDirty = function() { +Podfile.prototype.isDirty = function () { return this.__dirty; }; -Podfile.prototype.before_install = function() { +Podfile.prototype.before_install = function (toolOptions) { + toolOptions = toolOptions || {}; + // Template tokens in order: project name, project name, debug | release var template = - '// DO NOT MODIFY -- auto-generated by Apache Cordova\n' + + '// DO NOT MODIFY -- auto-generated by Apache Cordova\n' + '#include "Pods/Target Support Files/Pods-%s/Pods-%s.%s.xcconfig"'; var debugContents = util.format(template, this.projectName, this.projectName, 'debug'); @@ -188,10 +197,10 @@ Podfile.prototype.before_install = function() { fs.writeFileSync(debugConfigPath, debugContents, 'utf8'); fs.writeFileSync(releaseConfigPath, releaseContents, 'utf8'); - return Q.resolve(); + return Q.resolve(toolOptions); }; -Podfile.prototype.install = function(requirementsCheckerFunction) { +Podfile.prototype.install = function (requirementsCheckerFunction) { var opts = {}; opts.cwd = path.join(this.path, '..'); // parent path of this Podfile opts.stdio = 'pipe'; @@ -203,28 +212,34 @@ Podfile.prototype.install = function(requirementsCheckerFunction) { } return requirementsCheckerFunction() - .then(function() { - return self.before_install(); - }) - .then(function() { - return superspawn.spawn('pod', ['install', '--verbose'], opts) - .progress(function (stdio){ - if (stdio.stderr) { console.error(stdio.stderr); } - if (stdio.stdout) { - if (first) { - events.emit('verbose', '==== pod install start ====\n'); - first = false; - } - events.emit('verbose', stdio.stdout); - } + .then(function (toolOptions) { + return self.before_install(toolOptions); + }) + .then(function (toolOptions) { + if (toolOptions.ignore) { + events.emit('verbose', '==== pod install start ====\n'); + events.emit('verbose', toolOptions.ignoreMessage); + return Q.resolve(); + } else { + return superspawn.spawn('pod', ['install', '--verbose'], opts) + .progress(function (stdio) { + if (stdio.stderr) { console.error(stdio.stderr); } + if (stdio.stdout) { + if (first) { + events.emit('verbose', '==== pod install start ====\n'); + first = false; + } + events.emit('verbose', stdio.stdout); + } + }); + } + }) + .then(function () { // done + events.emit('verbose', '==== pod install end ====\n'); + }) + .fail(function (error) { + throw error; }); - }) - .then(function() { // done - events.emit('verbose', '==== pod install end ====\n'); - }) - .fail(function(error){ - throw error; - }); }; -module.exports.Podfile = Podfile;
\ No newline at end of file +module.exports.Podfile = Podfile; |
