Skip to content

Instantly share code, notes, and snippets.

@Rafi993
Created January 9, 2020 09:47
Show Gist options
  • Save Rafi993/67fa9c05ef32cca56af0e01f30211ac8 to your computer and use it in GitHub Desktop.
Save Rafi993/67fa9c05ef32cca56af0e01f30211ac8 to your computer and use it in GitHub Desktop.
vscode snippet generator from markdown
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