in lib/Podfile.js [280:344]
Podfile.prototype.write = function () {
let text = this.getTemplate();
const podsString =
Object.keys(this.pods).map(key => {
const name = key;
const json = this.pods[key];
if (typeof json === 'string') { // compatibility for using framework tag.
const spec = json;
if (spec.length) {
if (spec.indexOf(':') === 0) {
// don't quote it, it's a specification (starts with ':')
return util.format('\tpod \'%s\', %s', name, spec);
} else {
// quote it, it's a version
return util.format('\tpod \'%s\', \'%s\'', name, spec);
}
} else {
return util.format('\tpod \'%s\'', name);
}
} else {
const list = [`'${name}'`];
if ('spec' in json && json.spec.length) {
list.push(`'${json.spec}'`);
}
let options = ['tag', 'branch', 'commit', 'git', 'podspec']
.filter(tag => tag in json)
.map(tag => `:${tag} => '${json[tag]}'`);
if ('configurations' in json) {
options.push(`:configurations => [${json.configurations.split(',').map(conf => `'${conf.trim()}'`).join(',')}]`);
}
if ('options' in json) {
options = [json.options];
}
if (options.length > 0) {
list.push(options.join(', '));
}
return util.format('\tpod %s', list.join(', '));
}
}).join('\n');
const sourcesString =
Object.keys(this.sources).map(key => {
const source = this.sources[key];
return util.format('source \'%s\'', source);
}).join('\n');
const declarationString =
Object.keys(this.declarations).map(key => {
const declaration = this.declarations[key];
return declaration;
}).join('\n');
text = text.replace(this.podToken, podsString)
.replace(this.sourceToken, sourcesString)
.replace(this.declarationToken, declarationString);
fs.writeFileSync(this.path, text, 'utf8');
this.__dirty = false;
events.emit('verbose', 'Wrote to Podfile.');
};