Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Wello/Wello/config.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (34 sloc)
1.09 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const replace = require('replace'); | |
const et = require('elementtree'); | |
const ENV = require('./env'); | |
const src = { | |
android: (ENV === 'development' ? 'http://10.0.2.2:8080/' : '') + 'index.html', | |
ios: (ENV === 'development' ? 'http://localhost:8080/' : '') + 'index.html', | |
}; | |
const config = path.resolve('./config.xml'); | |
try { | |
var configXML = new et.ElementTree( | |
et.XML( | |
fs.readFileSync(config, 'utf-8') | |
) | |
); | |
configXML.getroot()._children.forEach(function(el) { | |
if (el.tag === 'platform') { | |
if (el.attrib.name === 'android' || el.attrib.name === 'ios') { | |
el._children.forEach(function(child) { | |
if (child.tag === 'content') { | |
console.log('Setting ' + el.attrib.name + ' src to ' + src[el.attrib.name]) | |
child.attrib.src = src[el.attrib.name]; | |
} | |
}); | |
} | |
} | |
}); | |
fs.writeFileSync(config, configXML.write({indent: 4}), 'utf-8'); | |
} catch (err) { | |
console.error('ERROR: Could not replace content src in: ' + config, err); | |
process.exit(1); | |
} |