mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-09 11:41:30 -07:00
[yarn] Add regen-version script
This commit is contained in:
parent
698584f7aa
commit
57b966d7c0
2 changed files with 18 additions and 1 deletions
|
@ -32,7 +32,8 @@
|
|||
"clean": "node ./scripts/clean.js",
|
||||
"clean-all": "node ./scripts/clean-all.js",
|
||||
"cleanall": "yarn clean-all",
|
||||
"focus-production": "node ./scripts/focus-production.js"
|
||||
"focus-production": "node ./scripts/focus-production.js",
|
||||
"regen-version": "node ./scripts/regen-version.js"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/backend",
|
||||
|
|
16
scripts/regen-version.js
Normal file
16
scripts/regen-version.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
const { join } = require("node:path");
|
||||
const fs = require("node:fs");
|
||||
const exec = require("execa");
|
||||
|
||||
(async () => {
|
||||
const file = join(__dirname, "../package.json");
|
||||
const json = require(file);
|
||||
|
||||
const match = json['version'].match(/^[\d.]*(?:-pre\d+|)?/);
|
||||
const version = match ? `${match[0]}-dev` : "dev";
|
||||
const { stdout: revision } = await exec("git", ["rev-parse", "--short", "HEAD"]);;
|
||||
|
||||
json['version'] = `${version}-${revision}`;
|
||||
console.log(json['version']);
|
||||
fs.writeFileSync(file, JSON.stringify(json, null, '\t'));
|
||||
})();
|
Loading…
Reference in a new issue