dedupe-csv
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -20,15 +20,22 @@ #!/usr/bin/env node | ||
const process_file_1 = __importDefault(require("./process-file")); | ||
const options_1 = __importDefault(require("./options")); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const options_1 = __importDefault(require("./options")); | ||
const { green } = chalk_1.default; | ||
const { cyan } = chalk_1.default; | ||
const validations_1 = __importDefault(require("./validations")); | ||
const Deduper = () => __awaiter(void 0, void 0, void 0, function* () { | ||
console.log('Working...'); | ||
console.log(cyan('Working...')); | ||
const { file, column, keep } = (0, options_1.default)(); | ||
const total = yield (0, line_counter_1.default)(file); | ||
if (file === '') { | ||
const filename = green(`file='name_of_file.csv'`); | ||
console.log(`No CSV included, please specify a csv file by using ${filename}`); | ||
process.exit(); | ||
let total; | ||
// Count number of lines if file accessible | ||
try { | ||
total = yield (0, line_counter_1.default)(file); | ||
} | ||
const filePath = (0, path_1.resolve)(process.cwd(), file); // Resolve the absolute file path | ||
catch (error) { | ||
if (file === '') | ||
(0, validations_1.default)('no-file'); | ||
else | ||
(0, validations_1.default)('incorrent-file', file); | ||
} | ||
// Resolve the absolute file path | ||
const filePath = (0, path_1.resolve)(process.cwd(), file); | ||
yield (0, process_file_1.default)(total, filePath, file, column, keep); | ||
@@ -38,2 +45,1 @@ }); | ||
(0, exports.Deduper)(); | ||
//# sourceMappingURL=index.js.map |
@@ -49,2 +49,1 @@ "use strict"; | ||
}); | ||
//# sourceMappingURL=line-counter.js.map |
@@ -6,4 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const { red } = chalk_1.default; | ||
const validations_1 = __importDefault(require("./validations")); | ||
exports.default = () => { | ||
@@ -22,4 +21,3 @@ const options = { | ||
else { | ||
console.log(red(`${label} is not a valid option`)); | ||
process.exit(); | ||
(0, validations_1.default)('label', label); | ||
} | ||
@@ -30,2 +28,1 @@ } | ||
}; | ||
//# sourceMappingURL=options.js.map |
@@ -20,2 +20,3 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const validations_1 = __importDefault(require("./validations")); | ||
const { cyan, yellow, green, red } = chalk_1.default; | ||
@@ -33,7 +34,5 @@ let progressCount = 0; | ||
if (!['first', 'last'].includes(keep) && typeof keep !== 'undefined') { | ||
console.log(red.bold(`${keep}`), 'Is not a valid option, please use only', green(`'first' 'last'`), 'as options'); | ||
process.exit(); | ||
(0, validations_1.default)('keep', keep); | ||
} | ||
(0, fs_1.createReadStream)(filePath) | ||
.on('error', () => console.log(`File not found, please make sure the correct file referenced it's on the same path where you are running the command`)) | ||
.pipe((0, csv_parser_1.default)()) | ||
@@ -47,4 +46,3 @@ .on('data', (obj) => { | ||
if (!dataHeaders.includes(header)) { | ||
console.log('The ' + red.bold(`${header}`), 'column not be found on the', green(`${file}`), 'file'); | ||
process.exit(); | ||
(0, validations_1.default)('headers', header, file); | ||
} | ||
@@ -54,2 +52,3 @@ } | ||
firstRound = false; | ||
console.clear(); | ||
bar.start(total, 0); | ||
@@ -102,2 +101,1 @@ } | ||
}); | ||
//# sourceMappingURL=process-file.js.map |
@@ -19,2 +19,1 @@ "use strict"; | ||
}; | ||
//# sourceMappingURL=progress.js.map |
@@ -44,2 +44,1 @@ "use strict"; | ||
}); | ||
//# sourceMappingURL=writer.js.map |
{ | ||
"name": "dedupe-csv", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"description": "A deduper for duplicated entries found on a CSV files", | ||
@@ -5,0 +5,0 @@ "author": "Alvaro Fernandez - Builtvisible", |
26610
22
327