Skip to content

Instantly share code, notes, and snippets.

@loopiezlol
Created May 10, 2018 11:54
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 loopiezlol/deaa2f11d41ac194f8d14dd4598c5b2f to your computer and use it in GitHub Desktop.
Save loopiezlol/deaa2f11d41ac194f8d14dd4598c5b2f to your computer and use it in GitHub Desktop.
const currPath = 'path';
const aspects = ['new', 'workout', 'blah'];
fs
.readDirSync(currPath)
.filter(folder => folder !== 'archived')
.forEach(topicName =>
fs
.readDirSync(path.join(currFolder, topicName))
.filter(folder => folder !== 'README.md')
.forEach(courseName =>
fs
.readDirSync(path.join(currFolder, topicName, courseName))
.filter(folder => folder !== 'README.md')
.forEach(workoutName =>
fs
.readDirSync(
path.join(currFolder, topicName, courseName, workoutName)
)
.filter(folder => folder !== 'README.md')
.forEach(insightName => {
const insightPath = path.join(
currFolder,
topicName,
courseName,
workoutName
);
const insightFile = fs.readFileSync(insightPath);
const insight = new Insight({ body: insightFile });
const insightAspects = insight.tags.filter(tag =>
aspects.includes(tag));
if (insightAspects.length) {
insight.aspects = insightAspects;
insight.tags = insight.tags.filter(
tag => !aspects.includes(tag)
);
const newInsightFile = insight.render();
fs.writeFileSync(insightPath, newInsightFile);
}
}))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment