From 18d251b015546adb0cd23074d598b01b18993b3d Mon Sep 17 00:00:00 2001 From: Pragyan Bhattacharya Date: Tue, 16 May 2017 16:57:16 +0530 Subject: [PATCH] Bug Fixes: Added support for multiple labels Multiple labels with comma separated value Signed-Off-By: Progyan Bhatatcharya --- .travis.yml | 1 - app.js | 4 ++-- lib/fetchissue.js | 6 ++++-- lib/fetchpulls.js | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5be77c..5363bf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,5 @@ branches: install: - npm install --ignore-scripts - npm link - - export NODEJS_ENV=development script: - npm test diff --git a/app.js b/app.js index f50aa59..9064ef4 100644 --- a/app.js +++ b/app.js @@ -33,9 +33,9 @@ const argv = process.argv, GHT = require('./lib/ght.js'), ver = require('./package.json').version, - DIR = process.env.NODEJS_ENV == 'development' ? __dirname : '~', + DIR = process.env.NODEJS_ENV == 'development' ? __dirname : (process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), CONFIG = path.resolve(DIR, '.ghb'), - FILE = curDir.replace(/[|&:;$%@"<>()+,\/\\\s]/g, '-'), + FILE = curDir.replace(/[|&:;$%@"<>()+,\/\\\s]+/g, '-'), helpStr = `Usage: ghb [options] [parameter] diff --git a/lib/fetchissue.js b/lib/fetchissue.js index 92a6f1a..4468fd0 100644 --- a/lib/fetchissue.js +++ b/lib/fetchissue.js @@ -16,8 +16,10 @@ var fetchIssue = (config, flag, callback) => { fg = '?state=' + flag.value else if (flag.key === 'id' && typeof flag.value == 'number') fg = '/' + flag.value.toString() - else if (flag.key === 'label' && typeof flag.value === 'string') - fg = '?labels=' + flag.value.replace(/[\s]/, '+') + else if (flag.key === 'label' && typeof flag.value === 'string'){ + let temp = flag.value.replace(/([,])[\s]/, ',') + fg = '?labels=' + temp.replace(/[\s]/, '+') + } else { let err = `Invalid argument specified for fetch issue.` throw err; diff --git a/lib/fetchpulls.js b/lib/fetchpulls.js index 8b5496e..c684171 100644 --- a/lib/fetchpulls.js +++ b/lib/fetchpulls.js @@ -16,8 +16,10 @@ var fetchPulls = (config, flag, callback) => { fg = '?state=' + flag.value else if (flag.key === 'id' && typeof flag.value == 'number') fg = '/' + flag.value.toString() - else if (flag.key === 'label' && typeof flag.value === 'string') - fg = '?labels=' + flag.value.replace(/[\s]/, '+') + else if (flag.key === 'label' && typeof flag.value === 'string'){ + let temp = flag.value.replace(/([,])[\s]/, ',') + fg = '?labels=' + temp.replace(/[\s]/, '+') + } else { let err = `Invalid argument specified for fetch pulls.` throw err;