[Chore] Update extractor for 30web
This commit is contained in:
@ -5,6 +5,7 @@ const fs = require('fs-extra'),
|
||||
frontmatter = require('front-matter'),
|
||||
babel = require('@babel/core');
|
||||
const config = require('../../config');
|
||||
const execSync = require('child_process').execSync;
|
||||
|
||||
// Reade all files in a directory
|
||||
const getFilesInDir = (directoryPath, withPath, exclude = null) => {
|
||||
@ -54,7 +55,7 @@ const getCodeBlocks = str => {
|
||||
});
|
||||
}
|
||||
const replacer = new RegExp(
|
||||
`\`\`\`${config.language}([\\s\\S]*?)\`\`\``,
|
||||
`\`\`\`${config.language.short}([\\s\\S]*?)\`\`\``,
|
||||
'g',
|
||||
);
|
||||
results = results.map(v => v.replace(replacer, '$1').trim());
|
||||
@ -102,6 +103,9 @@ const readSnippets = snippetsPath => {
|
||||
},
|
||||
meta: {
|
||||
hash: hashData(data.body),
|
||||
firstSeen: execSync(`git log --diff-filter=A --pretty=format:%at -- snippets/${snippet}`).toString(),
|
||||
lastUpdated: execSync(`git log -n 1 --pretty=format:%at -- snippets/${snippet}`).toString(),
|
||||
updateCount: execSync(`git log --pretty=%H -- snippets/${snippet}`).toString().split('\n').length
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -117,5 +121,5 @@ module.exports = {
|
||||
hashData,
|
||||
getCodeBlocks,
|
||||
getTextualContent,
|
||||
readSnippets,
|
||||
readSnippets
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user