forked from lerna/lerna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-tag.js
30 lines (22 loc) · 755 Bytes
/
git-tag.js
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
"use strict";
const log = require("npmlog");
const childProcess = require("@lerna/child-process");
module.exports.gitTag = gitTag;
/**
* @param {string} tag
* @param {{ forceGitTag: boolean; signGitTag: boolean; }} gitOpts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function gitTag(tag, { forceGitTag, signGitTag }, opts, command = "git tag %s -m %s") {
log.silly("gitTag", tag, command);
const [cmd, ...args] = command.split(" ");
const interpolatedArgs = args.map((arg) => arg.replace(/%s/, tag));
if (forceGitTag) {
interpolatedArgs.push("--force");
}
if (signGitTag) {
interpolatedArgs.push("--sign");
}
log.verbose(cmd, interpolatedArgs);
return childProcess.exec(cmd, interpolatedArgs, opts);
}