[Chore] Update extractor for 30web

This commit is contained in:
Angelos Chalaris
2019-11-06 19:19:37 +02:00
parent ec23f02c5f
commit d849ee91ba
7 changed files with 31 additions and 18 deletions

View File

@ -49,8 +49,8 @@ const getCodeBlocks = str => {
results.push(match);
});
}
const replacer = new RegExp(`\`\`\`${config.language}([\\s\\S]*?)\`\`\``, 'g');
const optionalReplacer = new RegExp(`\`\`\`${config.optionalLanguage}([\\s\\S]*?)\`\`\``, 'g');
const replacer = new RegExp(`\`\`\`${config.language.short}([\\s\\S]*?)\`\`\``, 'g');
const optionalReplacer = new RegExp(`\`\`\`${config.optionalLanguage.short}([\\s\\S]*?)\`\`\``, 'g');
results = results.map(v =>
v
.replace(replacer, '$1')
@ -103,7 +103,10 @@ const readSnippets = snippetsPath => {
tags: data.attributes.tags.split(',').map(t => t.trim())
},
meta: {
hash: hashData(data.body)
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
}
};
}