Skip to content

Commit

Permalink
feat: add cli support
Browse files Browse the repository at this point in the history
closes #3
  • Loading branch information
gligoran committed Apr 11, 2017
1 parent 35c10d2 commit b0722a5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"latest"
]
},
"bin": {
"cordova-set-version": "dist/cli.js"
},
"bugs": {
"url": "https://github.com/gligoran/cordova-set-version/issues"
},
Expand All @@ -14,6 +17,7 @@
}
},
"dependencies": {
"meow": "3.7.0",
"mz": "2.6.0",
"read-pkg": "2.0.0",
"xml2js": "0.4.17",
Expand Down
42 changes: 42 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

import meow from 'meow';

import setCordovaVersion from './index';

const help = `
Usage
$ cordova-set-version [-v|--version <version>] [-b|--build-number <build-number>] [config.xml]
Options
-v, --version Version to set
-b, --build-number Build number to set
Examples
$ cordova-set-version -v 2.4.9
$ cordova-set-version -b 86
$ cordova-set-version -v 2.4.9 -b 86
`;

const cli = meow(
{
version: false,
help
}, {
alias: {
v: 'version',
b: 'buildNumber'
}
}
);

const filename = cli.input[0] || 'config.xml';
let promise = Promise.resolve();

if (cli.flags.version) {
promise = promise.then(() => setCordovaVersion.setVersion(filename, cli.flags.version));
}

if (cli.flags.buildNumber) {
promise = promise.then(() => setCordovaVersion.setBuildNumber(filename, cli.flags.buildNumber));
}

0 comments on commit b0722a5

Please sign in to comment.