Skip to content

Commit

Permalink
Merge pull request #62 from pyscript/version-update
Browse files Browse the repository at this point in the history
Automatically update imports in `.md` files
  • Loading branch information
WebReflection committed Jan 31, 2024
2 parents b85bbf0 + 3d04929 commit 4afe14b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions version-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

const { join } = require('path');
const { readdirSync, readFileSync, statSync, writeFileSync } = require('fs');

const { version } = require(join(__dirname, 'version.json'));
const calVer = /\/\d{4}\.\d{1,2}\.\d{1,2}\//g;

const patch = directory => {
for (const file of readdirSync(directory)) {
const path = join(directory, file);
if (file.endsWith('.md')) {
writeFileSync(
path,
readFileSync(path).toString().replace(
calVer,
`/${version}/`
)
);
}
else if (statSync(path).isDirectory())
patch(path);
}
};

patch(join(__dirname, 'docs'));

0 comments on commit 4afe14b

Please sign in to comment.