Created
January 9, 2020 09:47
-
-
Save Rafi993/67fa9c05ef32cca56af0e01f30211ac8 to your computer and use it in GitHub Desktop.
vscode snippet generator from markdown
This file contains 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").promises; | |
const path = require("path"); | |
const listFiles = async folderName => { | |
const markDownFiles = (await fs.readdir(folderName)).filter(file => | |
file.includes(".md") | |
); | |
let snippet = {}; | |
for (const fileName of markDownFiles) { | |
const fileContent = await fs.readFile( | |
path.join(folderName, fileName), | |
"utf8" | |
); | |
snippet[fileName] = fileContent.split("\n"); | |
await fs.writeFile("snippet.json", JSON.stringify(snippet, null, 2)); | |
} | |
}; | |
listFiles("folderPath"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment