Skip to content

Commit

Permalink
use type-flag instead of yargs-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyor committed Jan 6, 2024
1 parent 08d8f05 commit 05e0fc3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"tsconfigRootDir": "__dirname"
},
"rules": {
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-floating-promises": "off"
"@typescript-eslint/unbound-method": "off"
},
"root": true
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
"dependencies": {
"cli-progress": "^3.12.0",
"ts-morph": "^19.0.0",
"yargs-parser": "^21.1.1"
"type-flag": "^3.0.0"
},
"devDependencies": {
"@types/cli-progress": "^3.11.0",
"@types/node": "^18.15.11",
"@types/yargs-parser": "^21.0.0",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"eslint": "^8.47.0",
Expand Down
22 changes: 7 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import path from 'path';

import { CompilerOptions, Node, Project, SourceFile, SyntaxKind, ts } from 'ts-morph';
import cliProgress from 'cli-progress';
import parser from 'yargs-parser'
import { typeFlag } from 'type-flag';

type Config = {
projectFiles: string;
workOn?: string;
};

const argv = parser(process.argv.slice(2), {
configuration: {
'strip-dashed': true
const parsed = typeFlag({
projectFiles: {
type: String,
alias: 'f',
},
string: ['projectFiles', 'workOn']
}) as unknown as Config;
workOn: {
type: String,
alias: 'w',
},
});

export const trimQuotes = (str: string) => {
return str.slice(1, -1);
Expand Down Expand Up @@ -355,9 +359,11 @@ export const migrateToNamedExport = (projectFiles: Config) => {
}
};

if (argv.projectFiles) {
migrateToNamedExport({
projectFiles: argv.projectFiles,
workOn: argv?.workOn || ''
if (parsed.flags.projectFiles) {
void migrateToNamedExport({
projectFiles: parsed.flags.projectFiles,
workOn: parsed.flags.workOn || ''
});
} else {
console.log('provide --project-files option');
}

0 comments on commit 05e0fc3

Please sign in to comment.