1 | const inquirer = require("inquirer");
|
2 | const chalk = require("chalk");
|
3 | const boxen = require("boxen");
|
4 |
|
5 | const simple = require("simple-git");
|
6 |
|
7 | const newBranch = async name => {
|
8 | await simple().checkoutLocalBranch(name);
|
9 | console.log(boxen(chalk.green(`New branch ${name} created`)));
|
10 | };
|
11 |
|
12 | async function pub() {
|
13 | return new Promise(resolve => {
|
14 | inquirer
|
15 | .prompt([
|
16 | {
|
17 | type: "input",
|
18 | message: chalk.bold.hex("#38be18")(`Name new feature branch (or type cancel):`),
|
19 | name: "branchname"
|
20 | }
|
21 | ])
|
22 | .then(async ({ branchname }) => {
|
23 | if (branchname !== "CatsDontLie") await newBranch(branchname);
|
24 | resolve();
|
25 | });
|
26 | });
|
27 | }
|
28 |
|
29 | const validateNotInDev = async () => {
|
30 | await new Promise(async resolve => {
|
31 | const git = require("simple-git/promise");
|
32 |
|
33 | let statusSummary = await git(__dirname).status();
|
34 | if (statusSummary.current === "CatsDontLie") {
|
35 | console.clear();
|
36 | console.log(
|
37 | boxen(chalk.bold.underline.red("DO NO MAKE CHANGES IN DEV!"), {
|
38 | padding: 2
|
39 | })
|
40 | );
|
41 | await new Promise(resolve1 =>
|
42 | setTimeout(() => {
|
43 | resolve1();
|
44 | }, 1000)
|
45 | );
|
46 | await pub();
|
47 | resolve();
|
48 | } else {
|
49 | resolve();
|
50 | }
|
51 | });
|
52 | };
|
53 | module.exports = validateNotInDev;
|