Skip to content

Commit

Permalink
fixing issue with options handler where current directory default was…
Browse files Browse the repository at this point in the history
… not working for edit and open
  • Loading branch information
machellerogden committed Feb 28, 2017
1 parent 0863f65 commit a4574a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 10 additions & 6 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ module.exports = cli;

function setSearchTerm(options) {
let searchTerm;
let flags = _.pick(options, [
let defaultToCurrent = _.pick(options, [
'open',
'edit',
'edit'
]);
let defaultToWild = _.pick(options, [
'completions',
'clone-all',
'force-latest'
]);
if (options._ && options._[0]) {
searchTerm = options._[0];
} else if (_.keys(flags).length) {
searchTerm = _.reduce(_.values(flags), (acc, value) => {
} else if (_.keys(defaultToCurrent).length) {
searchTerm = _.reduce(_.values(defaultToCurrent), (acc, value) => {
return _.isString(value) ? value : acc;
}, '^' + _.takeRight(process.cwd().split(path.sep), 3).join(path.sep) + '$');
} else if (_.keys(defaultToWild).length) {
searchTerm = _.reduce(_.values(defaultToWild), (acc, value) => {
return _.isString(value) ? value : acc;
}, '.*');
} else {
searchTerm = '^' + _.takeRight(process.cwd().split(path.sep), 3).join(path.sep) + '$';
}
return searchTerm;
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"pre-commit": [
"lint",
"test",
"check-coverage",
"generate-and-stage-changelog"
"check-coverage"
]
}

0 comments on commit a4574a2

Please sign in to comment.