-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change to update version.js from scripts
Changed it because it is easier and more testable than doing it from github actions
- Loading branch information
1 parent
9a42e3c
commit d12939c
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* This script reads the version from package.json and writes it to src/version.js. | ||
* It also stages the changes to src/version.js in git. | ||
* | ||
* Should be used as an [`npm version` script](https://docs.npmjs.com/cli/v8/using-npm/scripts#npm-version)! | ||
*/ | ||
import { execFile } from 'node:child_process' | ||
import { readFile, writeFile } from 'node:fs/promises' | ||
import { promisify } from 'node:util' | ||
|
||
async function main () { | ||
const packageJson = JSON.parse(await readFile('package.json', 'utf8')) | ||
const version = packageJson.version | ||
|
||
await writeFile('src/version.js', `export const version = '${version}'\n`) | ||
await promisify(execFile)('git', ['add', 'src/version.js']) | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |