Skip to content

Commit 3d04929

Browse files
committed
Automatically update imports in .md files
This MR simply crawls the docs to change the version accordingly with the one specified in `version.json` file.
1 parent b85bbf0 commit 3d04929

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

version-update.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env node
2+
3+
const { join } = require('path');
4+
const { readdirSync, readFileSync, statSync, writeFileSync } = require('fs');
5+
6+
const { version } = require(join(__dirname, 'version.json'));
7+
const calVer = /\/\d{4}\.\d{1,2}\.\d{1,2}\//g;
8+
9+
const patch = directory => {
10+
for (const file of readdirSync(directory)) {
11+
const path = join(directory, file);
12+
if (file.endsWith('.md')) {
13+
writeFileSync(
14+
path,
15+
readFileSync(path).toString().replace(
16+
calVer,
17+
`/${version}/`
18+
)
19+
);
20+
}
21+
else if (statSync(path).isDirectory())
22+
patch(path);
23+
}
24+
};
25+
26+
patch(join(__dirname, 'docs'));

0 commit comments

Comments
 (0)