Skip to content

Commit

Permalink
feat: remove lodash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tuler authored and codeandcats committed Apr 6, 2024
1 parent 70f9e95 commit 2451321
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 29 deletions.
13 changes: 3 additions & 10 deletions package-lock.json

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

2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -51,7 +51,6 @@
"@types/fs-extra": "8.1.0",
"@types/glob": "7.1.2",
"@types/jest": "^29.5.8",
"@types/lodash": "^4.14.201",
"coveralls": "3.1.0",
"get-root-path": "2.0.2",
"husky": "4.2.5",
Expand All @@ -72,7 +71,6 @@
"commander": "^11.1.0",
"fs-extra": "8.1.0",
"glob": "7.1.6",
"lodash": "^4.17.21",
"reflect-metadata": "0.1.13"
}
}
1 change: 0 additions & 1 deletion src/classy.ts
Expand Up @@ -3,7 +3,6 @@ import chalk = require('chalk');
import * as cli from 'commander';
import * as fs from 'fs-extra';
import * as glob from 'glob';
import * as _ from 'lodash';
import * as path from 'path';
import { setIocContainer } from './commander';
import { getUniqueModuleNames } from './modules';
Expand Down
7 changes: 2 additions & 5 deletions src/commander.ts
@@ -1,5 +1,4 @@
import * as cli from 'commander';
import * as _ from 'lodash';
import { coerceValue } from './coercion';
import { errorToString } from './errors';
import { getCommandOptions, getCommandValues } from './metadata';
Expand Down Expand Up @@ -132,16 +131,14 @@ function valueDefinitionToUsageString(value: CommandValueDefinition) {

export function getCommandDefinitionUsage(commandDefinition: CommandDefinition<any>) {
const values = getCommandValues(commandDefinition.paramsClass.prototype);
const valuesUsage = _
.chain(values)
const valuesUsage = values
.map((value, index) => ({
value,
index
}))
.sort((a, b) => a.value.variadic ? 1 : b.value.variadic ? -1 : a.index - b.index)
.map((valueAndIndex) => valueDefinitionToUsageString(valueAndIndex.value))
.join(' ')
.value();
.join(' ');
const usage = `${commandDefinition.name} ${valuesUsage}`.trim();
return usage;
}
Expand Down
18 changes: 8 additions & 10 deletions src/modules.ts
@@ -1,5 +1,3 @@
import * as _ from 'lodash';

function isFileNameTypeScriptOrJavaScript(fileName: string) {
return /.\.(ts|js)$/i.test(fileName);
}
Expand All @@ -13,13 +11,13 @@ function removeFileExtension(fileName: string) {
}

export function getUniqueModuleNames(fileNames: string[]) {
const moduleNames = _
.chain(fileNames)
.filter((fileName) => !isFileNameDeclarationFile(fileName))
.filter(isFileNameTypeScriptOrJavaScript)
.map(removeFileExtension)
.uniq()
.value();

const moduleNames = [
...new Set(
fileNames
.filter((filename) => !isFileNameDeclarationFile(filename))
.filter(isFileNameTypeScriptOrJavaScript)
.map(removeFileExtension)
),
];
return moduleNames;
}
3 changes: 2 additions & 1 deletion tsconfig.json
Expand Up @@ -10,7 +10,8 @@
"moduleResolution": "node",
"outDir": "./dist",
"skipLibCheck": true,
"strict": true
"strict": true,
"target": "ES2015"
},
"exclude": [
"./node_modules"
Expand Down

0 comments on commit 2451321

Please sign in to comment.