mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
rmDuplicates not dying when its output is piped
This commit is contained in:
parent
53bcdf5672
commit
6ef65fb26a
1 changed files with 13 additions and 10 deletions
|
@ -121,12 +121,9 @@ function removePossibleAnswersDuplicates(path) {
|
||||||
count++
|
count++
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let removed = 0
|
||||||
dirs.forEach((currDir) => {
|
dirs.forEach((currDir) => {
|
||||||
const contents = fs.readdirSync(path + '/' + currDir)
|
const contents = fs.readdirSync(path + '/' + currDir)
|
||||||
let removed = 0
|
|
||||||
log(
|
|
||||||
`Processing ${C('green')}${currDir}${C()} (${contents.length} files) ...`
|
|
||||||
)
|
|
||||||
|
|
||||||
contents.forEach((currFile) => {
|
contents.forEach((currFile) => {
|
||||||
const currPath = path + '/' + currDir + '/' + currFile
|
const currPath = path + '/' + currDir + '/' + currFile
|
||||||
|
@ -173,10 +170,8 @@ function removePossibleAnswersDuplicates(path) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
log(`Removed ${C('red')}${removed}${C()} files`)
|
|
||||||
hr()
|
|
||||||
})
|
})
|
||||||
|
log(`Removed ${C('red')}${removed}${C()} files total`)
|
||||||
|
|
||||||
log(`${C('green')}Deleting empty directories ...${C()}`)
|
log(`${C('green')}Deleting empty directories ...${C()}`)
|
||||||
count = dirs.length
|
count = dirs.length
|
||||||
|
@ -415,14 +410,19 @@ function hr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function log(text) {
|
function log(text) {
|
||||||
|
utils.AppendToFile(text, globalLog)
|
||||||
|
if (process.stdout.isTTY) {
|
||||||
process.stdout.clearLine()
|
process.stdout.clearLine()
|
||||||
process.stdout.cursorTo(0)
|
process.stdout.cursorTo(0)
|
||||||
|
}
|
||||||
|
|
||||||
console.log(text)
|
console.log(text)
|
||||||
utils.AppendToFile(text, globalLog)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeInSameLine(text, returnToLineStart) {
|
function writeInSameLine(text, returnToLineStart) {
|
||||||
|
if (!process.stdout.isTTY) {
|
||||||
|
return
|
||||||
|
}
|
||||||
process.stdout.clearLine()
|
process.stdout.clearLine()
|
||||||
process.stdout.cursorTo(0)
|
process.stdout.cursorTo(0)
|
||||||
process.stdout.write(text)
|
process.stdout.write(text)
|
||||||
|
@ -434,6 +434,9 @@ function writeInSameLine(text, returnToLineStart) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function printProgressBar(current, total) {
|
function printProgressBar(current, total) {
|
||||||
|
if (!process.stdout.isTTY) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const width = process.stdout.columns - 30
|
const width = process.stdout.columns - 30
|
||||||
|
|
||||||
if (width <= 0) {
|
if (width <= 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue