Created
May 10, 2018 11:54
-
-
Save loopiezlol/deaa2f11d41ac194f8d14dd4598c5b2f to your computer and use it in GitHub Desktop.
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 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