feat(commands): add the ability to sign conventional commits (#2)
This commit is contained in:
23
src/index.ts
23
src/index.ts
@@ -38,7 +38,10 @@ program
|
||||
program
|
||||
.command("commit")
|
||||
.description("Create a conventional commit")
|
||||
.action(async () => {
|
||||
.option("-S, --sign", "sign the commit")
|
||||
.action(async (options) => {
|
||||
const sign = options.sign ? true : false;
|
||||
|
||||
const config = await GetConfig();
|
||||
|
||||
intro("Creating a conventional commit");
|
||||
@@ -178,9 +181,11 @@ program
|
||||
}${body ? `\n\n${body}` : ``}`;
|
||||
|
||||
if (stageAll) {
|
||||
await simpleGit().add(".").commit(commitMessage);
|
||||
await simpleGit()
|
||||
.add(".")
|
||||
.commit(commitMessage, sign ? ["-S"] : []);
|
||||
} else {
|
||||
await simpleGit().commit(commitMessage);
|
||||
await simpleGit().commit(commitMessage, sign ? ["-S"] : []);
|
||||
}
|
||||
|
||||
note(commitMessage);
|
||||
@@ -372,7 +377,9 @@ program
|
||||
"Changes package.json version and creates a new commit with a tag"
|
||||
)
|
||||
.argument("<version>", "new version formatted in SemVer")
|
||||
.action(async (string: string) => {
|
||||
.option("-S, --sign", "sign the release commit and tag")
|
||||
.action(async (string: string, options) => {
|
||||
const sign = options.sign ? true : false;
|
||||
const version = string.replace("v", "");
|
||||
const packageFile = JSON.parse(
|
||||
(
|
||||
@@ -392,8 +399,12 @@ program
|
||||
|
||||
await simpleGit()
|
||||
.add(".")
|
||||
.commit(`chore(release): v${version}`)
|
||||
.addTag(`v${version}`);
|
||||
.commit(`chore(release): v${version}`, sign ? ["-S"] : [])
|
||||
.tag(
|
||||
sign
|
||||
? [`-s v${version}`, `-m "Version ${version}"`]
|
||||
: [`-a v${version}`, `-m "Version ${version}"`]
|
||||
);
|
||||
});
|
||||
|
||||
program.parse();
|
||||
|
||||
Reference in New Issue
Block a user