Skip to content

Commit 5d1724e

Browse files
author
junbao
committed
fix(yargs): use positionals to fix #14, #15
1 parent 6085d16 commit 5d1724e

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dpdm",
3-
"version": "3.7.0",
3+
"version": "3.7.1",
44
"description": "Analyze circular dependencies in your JavaScript/TypeScript projects.",
55
"keywords": [
66
"circular",
@@ -56,21 +56,21 @@
5656
"lint-staged": "^11.1.1",
5757
"npm-run-all": "^4.1.5",
5858
"prettier": "^2.3.2",
59-
"rollup": "^2.53.3",
59+
"rollup": "^2.56.0",
6060
"ts-jest": "^27.0.4",
6161
"ts-node": "^10.1.0"
6262
},
6363
"dependencies": {
6464
"@types/fs-extra": "^9.0.12",
6565
"@types/glob": "^7.1.4",
6666
"@types/yargs": "^17.0.2",
67-
"chalk": "^4.1.1",
67+
"chalk": "^4.1.2",
6868
"fs-extra": "^10.0.0",
6969
"glob": "^7.1.7",
7070
"ora": "^5.4.1",
7171
"tslib": "^2.3.0",
7272
"typescript": "^4.3.5",
73-
"yargs": "^17.0.1"
73+
"yargs": "^17.1.0"
7474
},
7575
"cliVersion": "8.8.4",
7676
"lint-staged": {

src/bin/dpdm.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@ import {
2525
async function main() {
2626
const argv = await yargs
2727
.strict()
28-
.usage('$0 [options] files...')
28+
.usage(
29+
'$0 [options] <files...>',
30+
"Analyze the files' dependencies.",
31+
(yargs) => {
32+
return yargs.positional('files', {
33+
description: 'The file paths or globs',
34+
demandOption: true,
35+
type: 'string',
36+
array: true,
37+
});
38+
},
39+
)
2940
.option('context', {
3041
type: 'string',
3142
desc: 'the context directory to shorten path, default is current directory',
@@ -96,7 +107,9 @@ async function main() {
96107
.alias('h', 'help')
97108
.wrap(Math.min(yargs.terminalWidth(), 100)).argv;
98109

99-
if (argv._.length === 0) {
110+
const files = argv.files as string[];
111+
112+
if (files.length === 0) {
100113
yargs.showHelp();
101114
console.log('\nMissing entry file');
102115
process.exit(1);
@@ -152,8 +165,6 @@ async function main() {
152165
onProgress,
153166
};
154167

155-
const files = argv._.filter((t) => typeof t === 'string') as string[];
156-
157168
parseDependencyTree(files, options)
158169
.then(async (tree) => {
159170
o.succeed(`[${ended}/${total}] Analyze done!`);

yarn.lock

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,14 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1:
11691169
ansi-styles "^4.1.0"
11701170
supports-color "^7.1.0"
11711171

1172+
chalk@^4.1.2:
1173+
version "4.1.2"
1174+
resolved "https://registry.nlark.com/chalk/download/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
1175+
integrity sha1-qsTit3NKdAhnrrFr8CqtVWoeegE=
1176+
dependencies:
1177+
ansi-styles "^4.1.0"
1178+
supports-color "^7.1.0"
1179+
11721180
char-regex@^1.0.2:
11731181
version "1.0.2"
11741182
resolved "https://registry.nlark.com/char-regex/download/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
@@ -3040,10 +3048,10 @@ rimraf@^3.0.0:
30403048
dependencies:
30413049
glob "^7.1.3"
30423050

3043-
rollup@^2.53.3:
3044-
version "2.53.3"
3045-
resolved "https://registry.nlark.com/rollup/download/rollup-2.53.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Frollup%2Fdownload%2Frollup-2.53.3.tgz#14b0e57f0874d4ad23bdbb13050cf70bcd1eabf7"
3046-
integrity sha1-FLDlfwh01K0jvbsTBQz3C80eq/c=
3051+
rollup@^2.56.0:
3052+
version "2.56.0"
3053+
resolved "https://registry.nlark.com/rollup/download/rollup-2.56.0.tgz#daa832955d2b58f1ed52a3c4c85b7d1adaf076d0"
3054+
integrity sha1-2qgylV0rWPHtUqPEyFt9GtrwdtA=
30473055
optionalDependencies:
30483056
fsevents "~2.3.2"
30493057

@@ -3683,10 +3691,10 @@ yargs@^16.0.3:
36833691
y18n "^5.0.5"
36843692
yargs-parser "^20.2.2"
36853693

3686-
yargs@^17.0.1:
3687-
version "17.0.1"
3688-
resolved "https://registry.nlark.com/yargs/download/yargs-17.0.1.tgz?cache=0&sync_timestamp=1620086465147&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fyargs%2Fdownload%2Fyargs-17.0.1.tgz#6a1ced4ed5ee0b388010ba9fd67af83b9362e0bb"
3689-
integrity sha1-ahztTtXuCziAELqf1nr4O5Ni4Ls=
3694+
yargs@^17.1.0:
3695+
version "17.1.0"
3696+
resolved "https://registry.nlark.com/yargs/download/yargs-17.1.0.tgz#0cd9827a0572c9a1795361c4d1530e53ada168cf"
3697+
integrity sha1-DNmCegVyyaF5U2HE0VMOU62haM8=
36903698
dependencies:
36913699
cliui "^7.0.2"
36923700
escalade "^3.1.1"

0 commit comments

Comments
 (0)