Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagit

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagit - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

lib/check-node-version.js

66

bin/swagit.js

@@ -6,4 +6,6 @@ #!/usr/bin/env node

const { yellow, magenta } = require('chalk');
const nodeVersion = require('node-version');
const checkUpdate = require('../lib/check-update');
const checkNodeVersion = require('../lib/check-node-version');
const handleEsc = require('../lib/handle-esc');
const { info, success, error } = require('../lib/message-prefix');

@@ -17,16 +19,5 @@ const {

if (nodeVersion.major < 6) {
console.error(
`${error} Now requires at least version 6 of Node. Please upgrade!`
);
process.exit(1);
}
checkNodeVersion();
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => {
if (chunk === '\u001b') {
// ESC
process.exit(0);
}
});
handleEsc();

@@ -37,5 +28,3 @@ args.option('d', 'Select branches which you want to delete');

const startCheckout = async () => {
const choices = await getBranches();
const startCheckout = async branches => {
const { branch } = await inquirer.prompt([

@@ -46,3 +35,3 @@ {

message: 'Which branch do you want to checkout?',
choices,
choices: branches,
},

@@ -56,6 +45,4 @@ ]);

const startDeleteBranches = async () => {
const choices = await getBranches();
const { branches } = await inquirer.prompt([
const startDeleteBranches = async branches => {
const { branches: selectedBranches } = await inquirer.prompt([
{

@@ -65,7 +52,7 @@ type: 'checkbox',

message: 'Which branches do you want to delete?',
choices,
choices: branches,
},
]);
if (branches.length === 0) {
if (selectedBranches.length === 0) {
console.log('No branch selected, exit.');

@@ -76,5 +63,5 @@ process.exit(1);

const messageSuffix =
branches.length === 1
selectedBranches.length === 1
? 'this branch?'
: `those ${yellow.bold(branches.length)} branches?`;
: `those ${yellow.bold(selectedBranches.length)} branches?`;

@@ -86,3 +73,3 @@ const { confirm } = await inquirer.prompt([

message: `Are you want to ${yellow.bold('DELETE')} ${messageSuffix}
${branches.join(', ')}`,
${selectedBranches.join(', ')}`,
},

@@ -100,3 +87,3 @@ ]);

const main = async () => {
const checkGitRepository = async () => {
const currentBranch = await checkGit();

@@ -112,7 +99,26 @@

console.log(`${info} Current branch is ${magenta(currentBranch)}`);
};
const getGitBranches = async () => {
const branches = await getBranches();
if (branches.length === 0) {
console.error(`${error} No other branches in the repository`);
process.exit(1);
}
return branches;
};
const main = async () => {
checkUpdate();
await checkGitRepository();
const branches = await getGitBranches();
if (flags.d) {
await startDeleteBranches();
await startDeleteBranches(branches);
} else {
await startCheckout();
await startCheckout(branches);
}

@@ -119,0 +125,0 @@ };

@@ -12,3 +12,3 @@ {

},
"version": "0.1.2",
"version": "0.1.3",
"bin": {

@@ -32,3 +32,4 @@ "sg": "./bin/swagit.js",

"node-version": "^1.1.3",
"simple-git": "^1.95.1"
"simple-git": "^1.95.1",
"update-check": "^1.5.2"
},

@@ -35,0 +36,0 @@ "devDependencies": {

@@ -1,4 +0,4 @@

# Swagit
![Swagit](https://i.imgur.com/kYSEMFD.png)
![Swagit](https://i.imgur.com/QBNMDxU.png)
[![Build Status](https://travis-ci.com/jigsawye/swagit.svg?branch=master)](https://travis-ci.com/jigsawye/swagit)

@@ -39,2 +39,3 @@ ## Usage

MIT © [jigsawye](https://jigsawye.com)
MIT © [Evan Ye](https://github.com/jigsawye)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc