Skip to content

Commit

Permalink
fix(yargs): use positionals to fix #14, #15
Browse files Browse the repository at this point in the history
  • Loading branch information
acrazing committed Aug 5, 2021
1 parent 6085d16 commit 5d1724e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
8 changes: 4 additions & 4 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "dpdm",
"version": "3.7.0",
"version": "3.7.1",
"description": "Analyze circular dependencies in your JavaScript/TypeScript projects.",
"keywords": [
"circular",
Expand Down Expand Up @@ -56,21 +56,21 @@
"lint-staged": "^11.1.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"rollup": "^2.53.3",
"rollup": "^2.56.0",
"ts-jest": "^27.0.4",
"ts-node": "^10.1.0"
},
"dependencies": {
"@types/fs-extra": "^9.0.12",
"@types/glob": "^7.1.4",
"@types/yargs": "^17.0.2",
"chalk": "^4.1.1",
"chalk": "^4.1.2",
"fs-extra": "^10.0.0",
"glob": "^7.1.7",
"ora": "^5.4.1",
"tslib": "^2.3.0",
"typescript": "^4.3.5",
"yargs": "^17.0.1"
"yargs": "^17.1.0"
},
"cliVersion": "8.8.4",
"lint-staged": {
Expand Down
19 changes: 15 additions & 4 deletions src/bin/dpdm.ts
Expand Up @@ -25,7 +25,18 @@ import {
async function main() {
const argv = await yargs
.strict()
.usage('$0 [options] files...')
.usage(
'$0 [options] <files...>',
"Analyze the files' dependencies.",
(yargs) => {
return yargs.positional('files', {
description: 'The file paths or globs',
demandOption: true,
type: 'string',
array: true,
});
},
)
.option('context', {
type: 'string',
desc: 'the context directory to shorten path, default is current directory',
Expand Down Expand Up @@ -96,7 +107,9 @@ async function main() {
.alias('h', 'help')
.wrap(Math.min(yargs.terminalWidth(), 100)).argv;

if (argv._.length === 0) {
const files = argv.files as string[];

if (files.length === 0) {
yargs.showHelp();
console.log('\nMissing entry file');
process.exit(1);
Expand Down Expand Up @@ -152,8 +165,6 @@ async function main() {
onProgress,
};
const files = argv._.filter((t) => typeof t === 'string') as string[];
parseDependencyTree(files, options)
.then(async (tree) => {
o.succeed(`[${ended}/${total}] Analyze done!`);
Expand Down
24 changes: 16 additions & 8 deletions yarn.lock
Expand Up @@ -1169,6 +1169,14 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.nlark.com/chalk/download/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha1-qsTit3NKdAhnrrFr8CqtVWoeegE=
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

char-regex@^1.0.2:
version "1.0.2"
resolved "https://registry.nlark.com/char-regex/download/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
Expand Down Expand Up @@ -3040,10 +3048,10 @@ rimraf@^3.0.0:
dependencies:
glob "^7.1.3"

rollup@^2.53.3:
version "2.53.3"
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"
integrity sha1-FLDlfwh01K0jvbsTBQz3C80eq/c=
rollup@^2.56.0:
version "2.56.0"
resolved "https://registry.nlark.com/rollup/download/rollup-2.56.0.tgz#daa832955d2b58f1ed52a3c4c85b7d1adaf076d0"
integrity sha1-2qgylV0rWPHtUqPEyFt9GtrwdtA=
optionalDependencies:
fsevents "~2.3.2"

Expand Down Expand Up @@ -3683,10 +3691,10 @@ yargs@^16.0.3:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.0.1:
version "17.0.1"
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"
integrity sha1-ahztTtXuCziAELqf1nr4O5Ni4Ls=
yargs@^17.1.0:
version "17.1.0"
resolved "https://registry.nlark.com/yargs/download/yargs-17.1.0.tgz#0cd9827a0572c9a1795361c4d1530e53ada168cf"
integrity sha1-DNmCegVyyaF5U2HE0VMOU62haM8=
dependencies:
cliui "^7.0.2"
escalade "^3.1.1"
Expand Down

0 comments on commit 5d1724e

Please sign in to comment.