find-duplicate-strings
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -24,3 +24,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const answer = yield inquirer_1.prompt({ | ||
const answer = yield (0, inquirer_1.prompt)({ | ||
name: this.name, | ||
@@ -27,0 +27,0 @@ message: this.message, |
export declare class Directory { | ||
private exclusions; | ||
private extensions; | ||
private readonly exclusions; | ||
private readonly extensions; | ||
private readonly path; | ||
@@ -5,0 +5,0 @@ constructor(directory: string, exclusions: string[], extensions: string[]); |
@@ -34,7 +34,7 @@ "use strict"; | ||
this.extensions = extensions; | ||
this.path = path_1.resolve(process.cwd(), directory); | ||
if (!fs_1.existsSync(this.path)) { | ||
this.path = (0, path_1.resolve)(process.cwd(), directory); | ||
if (!(0, fs_1.existsSync)(this.path)) { | ||
throw new Error('Directory does not exist, please pass a valid path.'); | ||
} | ||
if (!fs_1.statSync(this.path).isDirectory()) { | ||
if (!(0, fs_1.statSync)(this.path).isDirectory()) { | ||
throw new Error('Path does not point to a directory.'); | ||
@@ -48,8 +48,8 @@ } | ||
return __asyncGenerator(this, arguments, function* readdirRecursively_1() { | ||
const dirents = yield __await(fs_1.promises.readdir(path, { withFileTypes: true })); | ||
for (const dirent of dirents) { | ||
const stream = yield __await(fs_1.promises.readdir(path, { withFileTypes: true })); | ||
for (const dirent of stream) { | ||
if (this.exclusions.includes(dirent.name)) { | ||
continue; | ||
} | ||
const fullPath = path_1.resolve(path, dirent.name); | ||
const fullPath = (0, path_1.resolve)(path, dirent.name); | ||
if (dirent.isDirectory()) { | ||
@@ -59,3 +59,3 @@ yield __await(yield* __asyncDelegator(__asyncValues(this.readdirRecursively(fullPath)))); | ||
else { | ||
const extension = path_1.extname(dirent.name).substr(1); | ||
const extension = (0, path_1.extname)(dirent.name).substr(1); | ||
if (!this.extensions.length || this.extensions.includes(extension)) { | ||
@@ -62,0 +62,0 @@ yield yield __await(fullPath); |
@@ -6,6 +6,3 @@ "use strict"; | ||
static removeDotPrefix(str) { | ||
if (str.startsWith('.')) { | ||
return str.substr(1, str.length); | ||
} | ||
return str; | ||
return str.startsWith('.') ? str.substr(1, str.length) : str; | ||
} | ||
@@ -12,0 +9,0 @@ static process(extensions) { |
/// <reference types="node" /> | ||
import { Interface } from 'readline'; | ||
import type { Interface } from 'readline'; | ||
export declare class File { | ||
@@ -4,0 +4,0 @@ private name; |
@@ -29,3 +29,3 @@ "use strict"; | ||
doubleQuoteToggle = !doubleQuoteToggle; | ||
if (doubleQuoteToggle === false && characterSet.length) { | ||
if (!doubleQuoteToggle && characterSet.length) { | ||
this.storeMatch(characterSet, this.name); | ||
@@ -38,3 +38,3 @@ characterSet = ''; | ||
singleQuoteToggle = !singleQuoteToggle; | ||
if (singleQuoteToggle === false && characterSet.length) { | ||
if (!singleQuoteToggle && characterSet.length) { | ||
this.storeMatch(characterSet, this.name); | ||
@@ -45,3 +45,3 @@ characterSet = ''; | ||
} | ||
if (doubleQuoteToggle === true || singleQuoteToggle === true) { | ||
if (doubleQuoteToggle || singleQuoteToggle) { | ||
characterSet += line[i]; | ||
@@ -75,4 +75,4 @@ continue; | ||
readlineInterface() { | ||
return readline_1.createInterface({ | ||
input: fs_1.createReadStream(this.name, { encoding: 'utf8' }), | ||
return (0, readline_1.createInterface)({ | ||
input: (0, fs_1.createReadStream)(this.name, { encoding: 'utf8' }), | ||
terminal: false, | ||
@@ -79,0 +79,0 @@ }); |
@@ -39,5 +39,5 @@ "use strict"; | ||
outputToFile(output, filename) { | ||
const filePath = path_1.resolve(process.cwd(), filename); | ||
const filePath = (0, path_1.resolve)(process.cwd(), filename); | ||
const data = JSON.stringify(output, null, 2); | ||
fs_1.writeFileSync(`${filePath}.json`, data, { encoding: 'utf8' }); | ||
(0, fs_1.writeFileSync)(`${filePath}.json`, data, { encoding: 'utf8' }); | ||
} | ||
@@ -44,0 +44,0 @@ processFinding(finding) { |
@@ -10,3 +10,2 @@ interface Options { | ||
private readonly scannedDirs; | ||
private readonly store; | ||
private exclusions; | ||
@@ -13,0 +12,0 @@ private extensions; |
@@ -30,3 +30,2 @@ "use strict"; | ||
this.scannedDirs = []; | ||
this.store = store_1.Store; | ||
if (options.exclusions) { | ||
@@ -33,0 +32,0 @@ this.exclusions = exclusions_1.Exclusions.process(options.exclusions); |
export declare class Store { | ||
private static store; | ||
private static readonly store; | ||
static add(key: string, value: unknown): void; | ||
@@ -4,0 +4,0 @@ static update(key: string, value: unknown): void; |
127
package.json
{ | ||
"name": "find-duplicate-strings", | ||
"version": "2.1.0", | ||
"description": "Easy to use CLI that finds duplicate strings in a directory and stores them in a external file for easy reference", | ||
"author": "Erwin Heitzman", | ||
"homepage": "https://github.com/erwinheitzman/find-duplicate-strings/blob/master/README.md", | ||
"license": "MIT", | ||
"main": "lib/cli/index.js", | ||
"types": "lib/cli/index.d.ts", | ||
"bin": "lib/cli/index.js", | ||
"files": [ | ||
"/lib" | ||
], | ||
"scripts": { | ||
"prepare": "rm -rf lib coverage && tsc --newLine lf", | ||
"lint": "eslint ./src/**/*.ts --fix", | ||
"pretest": "npm run lint", | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/erwinheitzman/find-duplicate-strings.git" | ||
}, | ||
"keywords": [ | ||
"duplicate", | ||
"duplicates", | ||
"strings", | ||
"duplication", | ||
"scan", | ||
"find", | ||
"find-duplicate-strings" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/erwinheitzman/find-duplicate-strings/issues" | ||
}, | ||
"dependencies": { | ||
"commander": "^6.2.0", | ||
"inquirer": "^7.3.3" | ||
}, | ||
"devDependencies": { | ||
"@types/inquirer": "^7.3.1", | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.14.9", | ||
"@typescript-eslint/eslint-plugin": "^4.8.2", | ||
"@typescript-eslint/parser": "^4.8.2", | ||
"eslint": "^7.14.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"husky": "^4.3.0", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.1", | ||
"prettier": "^2.2.0", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.2" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged", | ||
"pre-push": "npm t" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts}": [ | ||
"eslint --fix" | ||
] | ||
} | ||
"name": "find-duplicate-strings", | ||
"version": "2.1.1", | ||
"description": "Easy to use CLI that finds duplicate strings in a directory and stores them in a external file for easy reference", | ||
"author": "Erwin Heitzman", | ||
"homepage": "https://github.com/erwinheitzman/find-duplicate-strings/blob/master/README.md", | ||
"license": "MIT", | ||
"main": "lib/cli/index.js", | ||
"types": "lib/cli/index.d.ts", | ||
"bin": "lib/cli/index.js", | ||
"files": [ | ||
"/lib" | ||
], | ||
"scripts": { | ||
"prepare": "husky install", | ||
"prepublishOnly": "tsc", | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/erwinheitzman/find-duplicate-strings.git" | ||
}, | ||
"keywords": [ | ||
"duplicate", | ||
"duplicates", | ||
"strings", | ||
"duplication", | ||
"scan", | ||
"find", | ||
"find-duplicate-strings", | ||
"search" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/erwinheitzman/find-duplicate-strings/issues" | ||
}, | ||
"dependencies": { | ||
"commander": "^8.2.0", | ||
"inquirer": "^8.2.0" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/recommended": "^1.0.1", | ||
"@types/inquirer": "^8.1.3", | ||
"@types/jest": "^27.0.2", | ||
"@types/node": "^16.11.0", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"husky": "^7.0.2", | ||
"jest": "^27.2.5", | ||
"lint-staged": "^11.2.3", | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^27.0.7", | ||
"typescript": "^4.4.4" | ||
}, | ||
"lint-staged": { | ||
"**/*.{js,ts}": [ | ||
"eslint --fix" | ||
], | ||
"**/*.{yml,json,md,ts,js}": [ | ||
"prettier --write" | ||
] | ||
} | ||
} |
@@ -28,8 +28,25 @@ ![ci](https://github.com/erwinheitzman/find-duplicate-strings/workflows/ci/badge.svg) | ||
Example: | ||
Example without passing any flags or arguments (you will be asked for input): | ||
```bash | ||
find-duplicate-strings . --exclusions node_modules --extensions ts,js -t 10 -s | ||
find-duplicate-strings | ||
``` | ||
Example with all the supported flags and arguments: | ||
```bash | ||
find-duplicate-strings --exclusions node_modules,coverage --extensions ts,js,json --treshold 10 --silent ./example/path | ||
``` | ||
Breakdown of flags: | ||
- `--exclusions node_modules,coverage` excludes any files and directories matching `node_modules` or `coverage` | ||
- `--extensions ts,js,json` includes any files that have one of the following extentions `.ts`, `.js` or `.json` | ||
- `--treshold 10` only outputs matches found greater than or equal to 10 | ||
- `--silent` runs the program in silent mode | ||
Breakdown of arguments: | ||
- `./example/path` this is the path to scan (can be absolute or relative) | ||
When done, if you aren't running in silent mode it will output a table containing it's first 10 findings: | ||
@@ -36,0 +53,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42779
47
845
91
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcli-spinners@2.9.2(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedcommander@8.3.0(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinquirer@8.2.6(transitive)
+ Addedis-interactive@1.0.0(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedora@5.4.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwcwidth@1.0.1(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
- Removedcommander@6.2.1(transitive)
- Removedinquirer@7.3.3(transitive)
- Removedrxjs@6.6.7(transitive)
- Removedtslib@1.14.1(transitive)
Updatedcommander@^8.2.0
Updatedinquirer@^8.2.0