-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { execSync } from 'child_process' | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
import * as url from 'url' | ||
|
||
// get branch name from local git command | ||
const branchName = execSync('git rev-parse --abbrev-ref HEAD') | ||
.toString('utf-8') | ||
.replace(/\//g, '-') | ||
.trim() | ||
|
||
// timestamp | ||
const timestamp = new Date().toISOString().replace(/[-:.]/g, '').slice(0, -1) | ||
|
||
const newVersion = `0.0.0-${branchName}.${timestamp}` | ||
|
||
// // change version in package.json | ||
execSync(`pnpm version --no-workspaces-update ${newVersion}`, { | ||
stdio: 'inherit', | ||
}) | ||
|
||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) | ||
|
||
// // Writes the new version to `./src/errors/version.ts`. | ||
const versionFilePath = path.join(__dirname, '../src/errors/version.ts') | ||
|
||
fs.writeFileSync(versionFilePath, `export const version = '${newVersion}'\n`) |