avil13-co 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,44 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.mergeBranch = void 0;
4
7
  const exec_1 = require("./exec");
5
8
  const color_1 = require("../color");
9
+ const inquirer_1 = __importDefault(require("inquirer"));
6
10
  //
7
11
  async function mergeBranch(branchName) {
8
12
  if (!branchName) {
9
13
  throw new Error('No branch...');
10
14
  }
11
- const checkoutCommand = `git merge ${branchName}`;
12
- console.log(' ' + color_1.clc.green('git merge', branchName) + '\n');
13
- const checkoutCommandResult = await (0, exec_1.exec)(checkoutCommand);
14
- console.log(checkoutCommandResult);
15
+ const currentBranch = await (0, exec_1.exec)('git rev-parse --abbrev-ref HEAD');
16
+ const message = [
17
+ color_1.clc._blue,
18
+ 'Do you want to merge branch ',
19
+ color_1.clc._green,
20
+ branchName,
21
+ color_1.clc._blue,
22
+ ' into ',
23
+ color_1.clc._green,
24
+ currentBranch,
25
+ color_1.clc._blue,
26
+ '?',
27
+ color_1.clc._off,
28
+ ].join('');
29
+ const res = await inquirer_1.default.prompt({
30
+ type: 'confirm',
31
+ name: 'answer',
32
+ message,
33
+ default: false,
34
+ });
35
+ if (res.answer === true) {
36
+ const checkoutCommand = `git merge ${branchName}`;
37
+ console.log(' ' + color_1.clc.green('git merge', branchName) + '\n');
38
+ const checkoutCommandResult = await (0, exec_1.exec)(checkoutCommand);
39
+ console.log(checkoutCommandResult);
40
+ return;
41
+ }
42
+ console.log(color_1.clc.yellow('The branch was not merged'));
15
43
  }
16
44
  exports.mergeBranch = mergeBranch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avil13-co",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "public": true,
@@ -1,5 +1,6 @@
1
1
  import { exec } from './exec';
2
2
  import { clc } from '../color';
3
+ import inquirer from 'inquirer';
3
4
 
4
5
  //
5
6
  export async function mergeBranch(branchName: string) {
@@ -7,10 +8,39 @@ export async function mergeBranch(branchName: string) {
7
8
  throw new Error('No branch...');
8
9
  }
9
10
 
10
- const checkoutCommand = `git merge ${branchName}`;
11
+ const currentBranch = await exec('git rev-parse --abbrev-ref HEAD');
11
12
 
12
- console.log(' ' + clc.green('git merge', branchName) + '\n');
13
+ const message = [
14
+ clc._blue,
15
+ 'Do you want to merge branch ',
16
+ clc._green,
17
+ branchName, // branch
18
+ clc._blue,
19
+ ' into ',
20
+ clc._green,
21
+ currentBranch, // branch
22
+ clc._blue,
23
+ '?',
24
+ clc._off,
25
+ ].join('');
13
26
 
14
- const checkoutCommandResult = await exec(checkoutCommand);
15
- console.log(checkoutCommandResult);
27
+ const res = await inquirer.prompt({
28
+ type: 'confirm',
29
+ name: 'answer',
30
+ message,
31
+ default: false,
32
+ });
33
+
34
+ if (res.answer === true) {
35
+ const checkoutCommand = `git merge ${branchName}`;
36
+
37
+ console.log(' ' + clc.green('git merge', branchName) + '\n');
38
+
39
+ const checkoutCommandResult = await exec(checkoutCommand);
40
+ console.log(checkoutCommandResult);
41
+
42
+ return;
43
+ }
44
+
45
+ console.log(clc.yellow('The branch was not merged'));
16
46
  }