Skip to content

Commit

Permalink
various fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
machellerogden committed Mar 6, 2017
1 parent d9cad3d commit ee7a8a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 0 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ const output = require('./lib/output');

module.exports = cli;

process.on('SIGINT', () => {
process.exit(1);
});

function setSearchTerm(options) {
let searchTerm;
let defaultToCurrent = _.pick(options, [
Expand Down
18 changes: 11 additions & 7 deletions dotfiles/cli.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
#!/usr/bin/env bash
function bitcar_cli() {
local workspace_dir="${BITCAR_WORKSPACE_DIR:-"$HOME/bitcar-repos"}"
function bitcar_cli {
local workspace_dir target cmd nbin
workspace_dir="${BITCAR_WORKSPACE_DIR:-"$HOME/bitcar-repos"}"

if [ -z "$1" ]; then
cd "$workspace_dir";
return
fi

local target="$HOME/.bitcar/.bitcar_target"
target="$HOME/.bitcar/.bitcar_target"

local cmd=()
local nbin="$(ls -d1 $HOME/n/n/versions/node/* | egrep '6\.\d\.\d' | tail -1 | tr -d '[:space:]')/bin/node"
cmd=()
nbin="$(ls -d1 $HOME/n/n/versions/node/* | egrep '6\.\d\.\d' | tail -1 | tr -d '[:space:]')/bin/node"
if [[ -x "$nbin" ]]; then
cmd+=( "$nbin" "$(which bitcar)" "$@" );
else
cmd=("bitcar" "$@")
fi

if "${cmd[@]}"; then
cd "$(cat "$target")"

[ -f "$target" ] && cd "$(cat "$target")" > /dev/null 2>&1

if [ "$1" = "--edit" ] || [ "$2" = "--edit" ] || [ "$1" = "-e" ] || [ "$2" = "-e" ]; then
if [ -n "$BITCAR_EDITOR_CMD" ]; then
"$BITCAR_EDITOR_CMD" "$(cat "$target")/"
fi
fi
rm "$target"

[ -f "$target" ] && rm "$target"
fi

}
Expand Down
9 changes: 6 additions & 3 deletions lib/syncExisting.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ function syncExisting() {
return acc;
}, {});

let sourceData = _.reduce(hosts, (acc, host) => {
acc[host] = _.unionBy(cache[host], entries[host], 'name');
return acc;
let sourceData = _.reduce(_.union(_.keys(entries, cache)), (kacc, key) => {
kacc[key] = _.reduce(_.union(_.map(cache[key], 'name'), _.map(entries[key], 'name')), (eacc, name) => {
eacc.push(_.assign({}, _.find(entries[key], { name }), _.find(cache[key], { name })));
return eacc;
}, []);
return kacc;
}, {});

sourceData['github.com'] = _.map(sourceData['github.com'] || [], (repo) => {
Expand Down

0 comments on commit ee7a8a7

Please sign in to comment.