Use current Jalali Date as NPM package version. run with zx.
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
#!/usr/bin/env zx | |
const branch = (await $`git branch --show-current`).stdout.trim(); | |
if (branch === "debug") { | |
const currentVersion = ( | |
await $`awk '/version/{gsub(/("|",)/,"",$2);print $2}' package.json` | |
).stdout.trim(); | |
const date = new Date(); | |
const jdate = date.toLocaleDateString("fa-IR-u-nu-latn"); | |
let version = jdate | |
.split("/") | |
.map((i) => i % 100) | |
.join("."); | |
if (currentVersion.startsWith(version)) | |
version += `-${parseInt(currentVersion.split("-")[1] || 1) + 1}`; | |
await $`npm version ${version} --no-git-tag-version`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in order to run, make sure zx is installed.
this script can be used as a git hook, take a look at husky.