find-duplicate-strings
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,6 +0,2 @@ | ||
import { Answers } from 'inquirer'; | ||
import { Findings } from '../scan'; | ||
export declare const outputFindings: (findings: Findings) => void; | ||
export declare const filterFileFormats: ({ scanPath }: Answers) => Promise<Answers>; | ||
export declare const scanDirAndLogFindings: ({ extensions, scanPath }: Answers) => Findings; | ||
export declare function run(): void; | ||
#!/usr/bin/env node | ||
export {}; |
@@ -0,52 +1,3 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.run = exports.scanDirAndLogFindings = exports.filterFileFormats = exports.outputFindings = void 0; | ||
const commander_1 = require("commander"); | ||
const inquirer_1 = require("inquirer"); | ||
const scan_1 = require("../scan"); | ||
const path_1 = require("path"); | ||
const fs_1 = require("fs"); | ||
const questions_json_1 = __importDefault(require("./questions.json")); | ||
const scanner = new scan_1.Scanner(); | ||
const program = new commander_1.Command(); | ||
const prompt = inquirer_1.createPromptModule(); | ||
exports.outputFindings = (findings) => { | ||
if (!Object.keys(findings).length) { | ||
console.log('No duplicates where found.'); | ||
return; | ||
} | ||
prompt([questions_json_1.default.write]).then(({ writePath }) => { | ||
const filePath = path_1.resolve(process.cwd(), writePath); | ||
const data = JSON.stringify(findings, null, 2); | ||
fs_1.writeFileSync(`${filePath}.json`, data, { encoding: 'utf8' }); | ||
}); | ||
}; | ||
exports.filterFileFormats = ({ scanPath }) => { | ||
return prompt([questions_json_1.default.extensions]).then(({ extensions }) => ({ extensions, scanPath })); | ||
}; | ||
exports.scanDirAndLogFindings = ({ extensions, scanPath }) => { | ||
const resolvedPath = path_1.resolve(process.cwd(), scanPath); | ||
if (!fs_1.existsSync(resolvedPath)) { | ||
throw new Error('Directory does not exist, please pass a valid path.'); | ||
} | ||
const findings = scanner.scanDir(resolvedPath, extensions); | ||
if (Object.keys(findings).length) { | ||
console.table(findings, ['count']); | ||
} | ||
return findings; | ||
}; | ||
function run() { | ||
prompt([questions_json_1.default.scan]) | ||
.then(exports.filterFileFormats) | ||
.then(exports.scanDirAndLogFindings) | ||
.then(exports.outputFindings) | ||
.catch((e) => { | ||
console.error(e); | ||
}); | ||
} | ||
exports.run = run; | ||
program.action(run); | ||
program.parse(process.argv); | ||
require('./cli'); |
{ | ||
"name": "find-duplicate-strings", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Easy to use CLI that finds duplicate strings in a directory and stores them in a external file for easy reference", | ||
@@ -5,0 +5,0 @@ "author": "Erwin Heitzman", |
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
10349
10
167