-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit-bump-package
executable file
·42 lines (31 loc) · 1.15 KB
/
commit-bump-package
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
// ##
// #% SYNOPSIS
// #% commit-bump-package <package_to_update>
// #% DESCRIPTION
// #% Script to stage and commit a bump message update of some package living under `packages`.
// #%
// #% AUTHOR
// #% Micael Levi L. C.
// #% COPYRIGHT
// #% Copyright © 2021 CodeMeistre.
// ##
const path = require('path')
const fs = require('fs')
const git = require('simple-git')
const PACKAGES_DIR_NAME = path.join(__dirname, 'packages')
const MANIFEST_FILENAME = 'package.json'
const [, , packageDirName] = process.argv
if (!packageDirName) {
throw new Error('Require a package directory name (living under `packages` directory)!')
}
const packageDir = path.join(PACKAGES_DIR_NAME, packageDirName)
const manifestFilePath = path.join(PACKAGES_DIR_NAME, packageDirName, MANIFEST_FILENAME)
const manifest = JSON.parse(fs.readFileSync(manifestFilePath, 'utf-8'))
const [, packageNameOnly] = manifest.name.split('/', 2)
process.env.HUSKY = '0'
const commitMsg = `chore(release): ${packageNameOnly}@v${manifest.version}`
git()
.add(packageDir)
.commit(commitMsg)
console.debug('Commit all on "%s" with the message "%s"', packageDir, commitMsg)