Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix security vuln
  • Loading branch information
jkup committed Feb 19, 2018
1 parent e71fbe1 commit 4fec455
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 55 deletions.
24 changes: 6 additions & 18 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "pullit",
"version": "1.3.0",
"version": "1.4.0",
"description": "Display and pull branches from GitHub pull requests",
"main": "src/index.js",
"preferGlobal": true,
Expand All @@ -12,13 +12,7 @@
"type": "git",
"url": "git+https://github.com/jkup/pullit.git"
},
"keywords": [
"github",
"pull",
"request",
"pr",
"cli"
],
"keywords": ["github", "pull", "request", "pr", "cli"],
"author": "Jon Kuperman",
"license": "MIT",
"bin": {
Expand All @@ -38,15 +32,9 @@
"terminal-menu": "^2.1.1"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.js"
],
"collectCoverageFrom": ["src/**/*.js"],
"testEnvironment": "node",
"modulePathIgnorePatterns": [
"__tests__/fixtures/"
],
"testPathIgnorePatterns": [
"__tests__/fixtures/"
]
"modulePathIgnorePatterns": ["__tests__/fixtures/"],
"testPathIgnorePatterns": ["__tests__/fixtures/"]
}
}
}
77 changes: 40 additions & 37 deletions src/index.js
@@ -1,9 +1,7 @@
const GitHubApi = require('github');
const Menu = require('terminal-menu');
const {
execSync
} = require('child_process');
const parse = require('parse-github-repo-url');
const GitHubApi = require("github");
const Menu = require("terminal-menu");
const { execFileSync } = require("child_process");
const parse = require("parse-github-repo-url");

class Pullit {
constructor() {
Expand All @@ -12,8 +10,8 @@ class Pullit {
}

init() {
const url = execSync(`git config --get remote.origin.url`, {
encoding: 'utf8'
const url = execFileSync("git", ["config", "--get", "remote.origin.url"], {
encoding: "utf8"
}).trim();

return this.parsedGithubUrl(url);
Expand All @@ -34,12 +32,11 @@ class Pullit {
})
.then(res => {
const branch = res.data.head.ref;
execSync(
`git fetch origin pull/${id}/head:${branch} && git checkout ${branch}`
);
execFileSync("git", ["fetch", "origin", `pull/${id}/head:${branch}`]);
execFileSync("git", ["checkout", branch]);
})
.catch(err => {
console.log('Error: Could not find the specified pull request.');
console.log("Error: Could not find the specified pull request.");
});
}

Expand All @@ -51,36 +48,42 @@ class Pullit {
}

display() {
this.fetchRequests().then(results => {
const menu = Menu({
width: process.stdout.columns - 4,
x: 0,
y: 2
});
menu.reset();
menu.write('Currently open pull requests:\n');
menu.write('-------------------------\n');
this.fetchRequests()
.then(results => {
const menu = Menu({
width: process.stdout.columns - 4,
x: 0,
y: 2
});
menu.reset();
menu.write("Currently open pull requests:\n");
menu.write("-------------------------\n");

results.data.forEach(element => {
menu.add(`${element.number} - ${element.title} - ${element.head.user.login}`);
});
results.data.forEach(element => {
menu.add(
`${element.number} - ${element.title} - ${element.head.user.login}`
);
});

menu.add(`Exit`);
menu.add(`Exit`);

menu.on('select', label => {
menu.close();
this.fetch(label.split(' ')[0]);
});
process.stdin.pipe(menu.createStream()).pipe(process.stdout);
menu.on("select", label => {
menu.close();
this.fetch(label.split(" ")[0]);
});
process.stdin.pipe(menu.createStream()).pipe(process.stdout);

process.stdin.setRawMode(true);
menu.on('close', () => {
process.stdin.setRawMode(false);
process.stdin.end();
process.stdin.setRawMode(true);
menu.on("close", () => {
process.stdin.setRawMode(false);
process.stdin.end();
});
})
.catch(err => {
console.log(
"Error: could not display pull requests. Please make sure this is a valid repository."
);
});
}).catch(err => {
console.log('Error: could not display pull requests. Please make sure this is a valid repository.')
});
}
}

Expand Down

0 comments on commit 4fec455

Please sign in to comment.