1 | "use strict";
|
2 |
|
3 | const { EOL } = require("os");
|
4 | const log = require("npmlog");
|
5 | const tempWrite = require("temp-write");
|
6 | const childProcess = require("@lerna/child-process");
|
7 |
|
8 | module.exports.gitCommit = gitCommit;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function gitCommit(message, { amend, commitHooks, signGitCommit }, opts) {
|
16 | log.silly("gitCommit", message);
|
17 | const args = ["commit"];
|
18 |
|
19 | if (commitHooks === false) {
|
20 | args.push("--no-verify");
|
21 | }
|
22 |
|
23 | if (signGitCommit) {
|
24 | args.push("--gpg-sign");
|
25 | }
|
26 |
|
27 | if (amend) {
|
28 | args.push("--amend", "--no-edit");
|
29 | } else if (message.indexOf(EOL) > -1) {
|
30 |
|
31 | args.push("-F", tempWrite.sync(message, "lerna-commit.txt"));
|
32 | } else {
|
33 | args.push("-m", message);
|
34 | }
|
35 |
|
36 | log.verbose("git", args);
|
37 | return childProcess.exec("git", args, opts);
|
38 | }
|