Created
May 27, 2019 14:31
-
-
Save nash403/de5d48586ff759fd653930a5b53223f9 to your computer and use it in GitHub Desktop.
List file names in current directory (without extension)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const path = require('path') | |
const files = [] | |
fs.readdirSync(__dirname).forEach(file => { | |
const i = file.indexOf(path.basename(file)) | |
const j = file.indexOf(path.extname(file)) | |
files.push(file.substring(i, j)) | |
}) | |
console.log(JSON.stringify(files, null, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment