-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automate the version change of Express #1643
Automate the version change of Express #1643
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bjohansebas 👋
Great job on automating this 💯, I am generally 👍 on this. However, would you be open to something like this? Perhaps we should make consistent use of await
.
I have also added error-handling just to feel safe.
import { readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
const NPMURL = 'https://registry.npmjs.org/express'
const response = await (await fetch(NPMURL)).json();
const { next, latest } = response['dist-tags']
try {
const filePath = path.resolve(path.join('_data', 'express.yml'));
let content = await readFile(filePath, 'utf8');
content = content.replace(/current_version: ".*"/, `current_version: "${latest}"`);
content = content.replace(/next_version: ".*"/, `next_version: "${next}"`);
await writeFile(filePath, content, 'utf8');
} catch (error) {
console.error('Error updating versions in _data/express.yml:', error);
}
3d59273
to
be5705f
Compare
Thanks @IamLizu for the suggestions. |
* create get-express-version script * improve script and catch error * update title
This script automates the process of changing the version number in the documentation, see #1504.
To ensure the workflow functions correctly, please review #1606