Skip to content

Commit

Permalink
fixing setup and issue with completions
Browse files Browse the repository at this point in the history
  • Loading branch information
machellerogden committed Feb 10, 2017
1 parent ae522f3 commit abc7b32
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function main(options) {
searchTerm = options.open;
} else if (options._ && options._[0]) {
searchTerm = options._[0];
} else {
} else if (!options.completions) {
searchTerm = _.takeRight(process.cwd().split(path.sep), 3).join(path.sep);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/getSourceData.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ function getSourceData(forceRefresh = false) {
if (fs.existsSync(path.normalize(__dirname + '/../sources/.cache.json')) && !forceRefresh) {
return Promise.resolve(require(__dirname + '/../sources/.cache.json'));
} else {
console.log('No cache found.');
const sources = require('../sources');
console.log('Loading cache now. This will only happen once.');
console.log('In the future, to refresh the cache run `bitcar --refresh`.');
return Promise.props(_.mapValues(sources, (source) => source(rc))).then((sourceData) => {
return new Promise(function (resolve, reject) {
return fs.writeFile(path.normalize(__dirname + '/../sources/.cache.json'), JSON.stringify(sourceData, null, 4), 'utf8', function (err) {
Expand Down
8 changes: 5 additions & 3 deletions setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ inquirer.prompt([
const path = require('path');

const profileContent = `
# begin bitcar sources
# begin bitcar
export BITCAR_ROOT_DIR='${answers.rootDir}'
source $HOME/.bitcar/cli.sh
source $HOME/.bitcar/completions.sh
# end bitcar sources
# end bitcar
`
const configContent = {
sources: []
Expand All @@ -76,7 +76,9 @@ source $HOME/.bitcar/completions.sh
fs.copyTpl(path.normalize(__dirname + '/dotfiles/completions.sh'), path.normalize(process.env.HOME + '/.bitcar/completions.sh'), answers);
fs.copy(path.normalize(__dirname + '/dotfiles/strip_codes'), path.normalize(process.env.HOME + '/.bitcar/strip_codes'));
fs.copy(path.normalize(process.env.HOME + '/.bash_profile'), path.normalize(process.env.HOME + '/.bash_profile.bkup'));
fs.append(path.normalize(process.env.HOME + '/.bash_profile'), profileContent);
const bashProfile = fs.read(path.normalize(process.env.HOME + '/.bash_profile'));
const cleanedProfile = bashProfile.replace(/\n# begin bitcar[\s\S]+# end bitcar\n/gm, profileContent);
fs.write(path.normalize(process.env.HOME + '/.bash_profile'), cleanedProfile);

fs.commit(function (err) {
if (err) return console.error(err)
Expand Down

0 comments on commit abc7b32

Please sign in to comment.