Skip to content

Commit 29a7162

Browse files
committed
Add script to fetch rfc-frontmatter as JSON
1 parent 0b02158 commit 29a7162

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

rfc-frontmatter.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const argv = require('yargs').command(
2+
'* path',
3+
'return the frontmatter of the RFC as JSON',
4+
(yargs) => {
5+
return yargs
6+
.positional('path', {
7+
describe: 'file path of the RFC',
8+
type: 'string',
9+
})
10+
.demandOption(['path']);
11+
}
12+
).argv;
13+
14+
const frontmatter = require('@github-docs/frontmatter');
15+
const { readFileSync } = require('fs');
16+
17+
let markdown = readFileSync(argv.path, 'utf8');
18+
const { data, errors } = frontmatter(markdown);
19+
20+
if (errors.length) {
21+
console.error(JSON.stringify(errors));
22+
process.exitCode = 1;
23+
return;
24+
}
25+
26+
console.log(JSON.stringify(data));

0 commit comments

Comments
 (0)