Build script updates config.xml file for cordova build process.
This commit is contained in:
parent
8a221f1969
commit
1b9abd897d
|
@ -5,6 +5,7 @@ const uuid = require('uuid').v4
|
|||
const PACKAGE = require('../package.json')
|
||||
|
||||
const INDEX = './www/index.html'
|
||||
const CONFIG = './config.xml'
|
||||
|
||||
function patch (versionStr) {
|
||||
const parts = versionStr.split('.');
|
||||
|
@ -16,16 +17,31 @@ async function main () {
|
|||
const build = uuid()
|
||||
const short = build.split('-')[0]
|
||||
const index = fs.readFileSync(INDEX, 'utf8')
|
||||
const lines = index.split('\n')
|
||||
const config = fs.readFileSync(CONFIG, 'utf8')
|
||||
let lines = index.split('\n')
|
||||
let output
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].indexOf('id="version"') !== -1) {
|
||||
lines[i] = ` <div id="version">v${PACKAGE.version} build ${short}</div>`
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
output = lines.join('\n')
|
||||
fs.writeFileSync(INDEX, output, 'utf8')
|
||||
|
||||
lines = config.split('\n')
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].indexOf('id="com.sixteenmillimeter.intval3"') !== -1) {
|
||||
lines[i] = `<widget id="com.sixteenmillimeter.intval3" version="${PACKAGE.version}" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">`
|
||||
break
|
||||
}
|
||||
}
|
||||
output = lines.join('\n')
|
||||
fs.writeFileSync(INDEX, output, 'utf8')
|
||||
fs.writeFileSync(CONFIG, output, 'utf8')
|
||||
|
||||
}
|
||||
|
||||
main()
|
Loading…
Reference in New Issue