Skip to content

Commit 069a397

Browse files
committed
move from argv to commander
1 parent 3a69cfa commit 069a397

File tree

3 files changed

+79
-21
lines changed

3 files changed

+79
-21
lines changed

package-lock.json

Lines changed: 61 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"babel-eslint": "^10.1.0",
5151
"broccoli-asset-rev": "^3.0.0",
5252
"chai": "^4.3.4",
53+
"commander": "^11.1.0",
5354
"compare-versions": "^6.0.0-rc.2",
5455
"ember-auto-import": "^2.6.1",
5556
"ember-cli": "~3.28.6",

scripts/update-version-links

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/node
1+
#!/usr/bin/env node
22

33
/**
44
* Search & Replace previous release numbers
@@ -26,6 +26,16 @@
2626
*/
2727

2828
const fs = require('fs');
29+
const { Command } = require('commander');
30+
const program = new Command();
31+
program.option('--tests')
32+
.option('--dry-run')
33+
.option('--verbose')
34+
.option('--silent')
35+
.argument('[currentFolder]')
36+
.argument('[newVersionNumber]');
37+
program.parse(process.argv);
38+
const options = program.opts();
2939

3040
const replaceURLsVersions = (str, version) => {
3141
let output;
@@ -88,24 +98,17 @@ const runTests = () => {
8898
console.log(test === 'https://guides.emberjs.com/v3.16.0/getting-started/' ? '✅' : '❌', test);
8999
};
90100

91-
if (process.argv[2] === '--tests') {
101+
if (options.tests) {
92102
runTests();
93103
process.exit(0);
94104
}
95105

96-
const currentFolder = fs.realpathSync(process.argv[2]);
97-
const newVersionNumber = process.argv[3];
106+
const currentFolder = fs.realpathSync(program.args[0]);
107+
const newVersionNumber = program.args[1];
98108

99-
let dryRun = false;
100-
let verbose = false;
101-
let silent = false;
102-
103-
if (process.argv.length > 4) {
104-
const options = process.argv.slice(4);
105-
dryRun = options.includes('--dry-run');
106-
verbose = options.includes('--verbose');
107-
silent = options.includes('--silent');
108-
}
109+
let dryRun = options.dryRun;
110+
let verbose = options.verbose;
111+
let silent = options.silent;
109112

110113
let filesFound = [];
111114
let filesUpdated = [];

0 commit comments

Comments
 (0)