You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
431 B
JavaScript
21 lines
431 B
JavaScript
const { readdir } = require('fs/promises')
|
|
const { join } = require('path')
|
|
|
|
const readdirScoped = async (dir) => {
|
|
const results = []
|
|
|
|
for (const item of await readdir(dir)) {
|
|
if (item.startsWith('@')) {
|
|
for (const scopedItem of await readdir(join(dir, item))) {
|
|
results.push(join(item, scopedItem))
|
|
}
|
|
} else {
|
|
results.push(item)
|
|
}
|
|
}
|
|
|
|
return results
|
|
}
|
|
|
|
module.exports = readdirScoped
|