Skip to content

Commit a5a1947

Browse files
committed
fix(version-error): Resolve versioning error
by default read package.json version
1 parent d01d7e1 commit a5a1947

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

cli.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
'use strict';
33

44
const meow = require('meow');
5-
const configXml = require('./');
5+
const configPluginXml = require('./');
66

77
const cli = meow({
88
help: [`
99
Usage
10-
See https://github.com/mifi/cordova-xml
11-
$ cordova-xml <action> <args>
10+
See https://github.com/hypery2k/cordova-plugin-xml
11+
$ cordova-plugin-xml <action> <args>
1212
Options
1313
--config Config path
1414
`]
1515
});
1616

1717
try {
18-
const config = configXml(cli.flags.config);
18+
const config = configPluginXml(cli.flags.config);
1919
const action = cli.input.shift();
2020
const args = cli.input;
2121

index.js

100644100755
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
'use strict';
22

33
const xmlpoke = require('xmlpoke');
4+
const packageJSON = require(process.cwd() + '/package.json');
45

5-
module.exports = configxml;
6+
console.log(process.cwd())
67

7-
function configxml(inFile) {
8+
function configpluginxml(inFile) {
89
const defaultFile = 'plugin.xml';
10+
const packageFile = 'package.json';
911
const file = inFile || defaultFile;
1012

1113
function poke(cb) {
1214
// https://github.com/mikeobrien/node-xmlpoke/issues/3
13-
xmlpoke(file, xml => cb(xml.addNamespace('w', 'http://www.w3.org/ns/widgets')));
15+
xmlpoke(file, xml => cb(xml.addNamespace('p', 'http://apache.org/cordova/ns/plugins/1.0')));
1416
}
1517

1618
function set(xpath, val) {
1719
poke(xml => xml.setOrAdd(xpath, val));
1820
}
1921

22+
function setVersion(xpath, val) {
23+
poke(xml => xml.setOrAdd(xpath, val || packageJSON.version));
24+
}
25+
2026
return {
21-
setVersion: set.bind(null, '/p:plugin/@version'),
27+
setVersion: setVersion.bind(null, '/p:plugin/@version'),
2228
withPoke: poke,
2329
}
2430
}
31+
32+
33+
module.exports = configpluginxml;

0 commit comments

Comments
 (0)