mirror of
https://github.com/SileNce5k/jscripts.git
synced 2025-04-19 11:08:24 +02:00
Improve tings n shit
This commit is contained in:
parent
8cf3c29008
commit
78a98e70cc
1 changed files with 5 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
// First arg is path to file
|
// First arg is path to file
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
|
||||||
function argHandler(args){
|
function argHandler(args){
|
||||||
|
@ -34,11 +35,11 @@ function cleanFile(pathToTextFile) {
|
||||||
let file = fs.readFileSync(pathToTextFile).toString();
|
let file = fs.readFileSync(pathToTextFile).toString();
|
||||||
const regex = /(\[)(.*)(\])/gm
|
const regex = /(\[)(.*)(\])/gm
|
||||||
file = file.replace(regex, "");
|
file = file.replace(regex, "");
|
||||||
fs.writeFileSync(`CLEANED.txt`, file);
|
let newPath = `CLEANED_${path.basename(pathToTextFile)}`
|
||||||
|
fs.writeFileSync(newPath, file);
|
||||||
|
console.log(`\nWrote new file to ${newPath}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let pathToTextFile = argHandler(process.argv);
|
let pathToTextFile = argHandler(process.argv);
|
||||||
|
|
||||||
fs.existsSync(pathToTextFile) ? cleanFile(pathToTextFile) : fileNotFound(pathToTextFile)
|
fs.existsSync(pathToTextFile) ? cleanFile(pathToTextFile) : fileNotFound(pathToTextFile)
|
||||||
|
|
||||||
console.log(process.argv[2])
|
|
Loading…
Add table
Reference in a new issue