Skip to content

Instantly share code, notes, and snippets.

@maximilian-lindsey
Created November 4, 2020 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximilian-lindsey/0843c24f3520d00ecd363e3e8377a2f7 to your computer and use it in GitHub Desktop.
Save maximilian-lindsey/0843c24f3520d00ecd363e3e8377a2f7 to your computer and use it in GitHub Desktop.
Duplicate content with JS
const fs = require('fs-extra');
const glob = require('glob');
const promisify = require('util.promisify');
const globAsync = promisify(glob);
const getAllFiles = async () => {
const allFiles = await globAsync('../content/**/*.de.md');
for (const file of allFiles) {
await fs.copy(file, file.replace('.de.md','.test.md'));
}
}
(async () => {
await getAllFiles();
})();
{
"name": "duplciate-content",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"fs-extra": "^9.0.1",
"glob": "^7.1.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment