UNPKG

1.53 kBJavaScriptView Raw
1const inquirer = require("inquirer");
2const chalk = require("chalk");
3const boxen = require("boxen");
4
5const simple = require("simple-git");
6
7const newBranch = async name => {
8 await simple().checkoutLocalBranch(name);
9 console.log(boxen(chalk.green(`New branch ${name} created`)));
10};
11
12async 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
29const 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};
53module.exports = validateNotInDev;