mirror of
https://github.com/cupcakearmy/canihazusername.git
synced 2025-09-05 23:00:40 +00:00
cleanup & updates
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* jshint esversion: 8, asi: true */
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const util = require('util')
|
||||
@@ -7,35 +5,36 @@ const util = require('util')
|
||||
const endsWithTxt = /^.*\.txt$/
|
||||
|
||||
function walkDir(dir, callback) {
|
||||
fs.readdirSync(dir).forEach(f => {
|
||||
const dirPath = path.join(dir, f)
|
||||
const isDirectory = fs.statSync(dirPath).isDirectory()
|
||||
isDirectory
|
||||
? walkDir(dirPath, callback)
|
||||
: callback(path.join(dir, f))
|
||||
})
|
||||
fs.readdirSync(dir).forEach((f) => {
|
||||
const dirPath = path.join(dir, f)
|
||||
const isDirectory = fs.statSync(dirPath).isDirectory()
|
||||
isDirectory ? walkDir(dirPath, callback) : callback(path.join(dir, f))
|
||||
})
|
||||
}
|
||||
|
||||
function convertAndSaveWordlistAsJSON() {
|
||||
const wordlist = {}
|
||||
const wordlist = {}
|
||||
|
||||
walkDir('./generate/wordlist', (filename) => {
|
||||
// Not a txt file
|
||||
if (!endsWithTxt.test(filename)) return
|
||||
walkDir('./generate/wordlist', (filename) => {
|
||||
// Not a txt file
|
||||
if (!endsWithTxt.test(filename)) return
|
||||
|
||||
// Read the file
|
||||
const file = fs.readFileSync(filename, 'utf-8')
|
||||
// Read the file
|
||||
const file = fs.readFileSync(filename, 'utf-8')
|
||||
|
||||
// Each line of the file to an array removing the empty lines
|
||||
const lines = file.split('\n').filter(entry => entry !== '').map(entry => entry.trim())
|
||||
// Each line of the file to an array removing the empty lines
|
||||
const lines = file
|
||||
.split('\n')
|
||||
.filter((entry) => entry !== '')
|
||||
.map((entry) => entry.trim())
|
||||
|
||||
// Remove duplicates
|
||||
const set = new Set(lines)
|
||||
const name = path.basename(filename, 'utf-8').slice(0, -4)
|
||||
wordlist[name] = [...set]
|
||||
})
|
||||
// Remove duplicates
|
||||
const set = new Set(lines)
|
||||
const name = path.basename(filename, 'utf-8').slice(0, -4)
|
||||
wordlist[name] = [...set]
|
||||
})
|
||||
|
||||
fs.writeFileSync('./src/wordlist.json', JSON.stringify(wordlist))
|
||||
fs.writeFileSync('./src/wordlist.json', JSON.stringify(wordlist))
|
||||
}
|
||||
|
||||
convertAndSaveWordlistAsJSON()
|
||||
convertAndSaveWordlistAsJSON()
|
||||
|
Reference in New Issue
Block a user