Skip to content

Commit

Permalink
big fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
machellerogden committed Feb 14, 2017
1 parent 9d98977 commit 65f7baa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
14 changes: 6 additions & 8 deletions lib/getSourceData.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ function getSourceData(forceRefresh = false) {
const config = fs.readJSON(path.normalize(process.env.HOME + '/.bitcar/config'));
const sources = require('../sources');
console.log('Loading cache...');
let sourceKeys = _.keys(sources);
let sourceValues = _.values(sources);
return Promise.mapSeries(sourceValues, (source) => source(rc))
return Promise.props(_.mapValues(sources, source => source(rc)))
.then((sourceData) => {
let mappedSourceData = _.zipObject(sourceKeys, sourceData);
mappedSourceData = _.mapValues(mappedSourceData, _.flow(_.flattenDeep, _.compact));
mappedSourceData = _.mapValues(mappedSourceData, (entries) => _.uniqBy(entries, 'name'));
sourceData = _.mapValues(sourceData, _.flow(_.flattenDeep, _.compact));
sourceData = _.mapValues(sourceData, (entries) => _.uniqBy(entries, 'name'));
return new Promise((resolve, reject) => {
fs.writeJSON(path.normalize(__dirname + '/../sources/.cache.json'), mappedSourceData, null, 4);
fs.writeJSON(path.normalize(__dirname + '/../sources/.cache.json'), sourceData, null, 4);
fs.commit((err) => {
if (err) return reject(err);
return resolve(mappedSourceData);
console.log('Cache set successfully');
return resolve(sourceData);
});
});
});
Expand Down
8 changes: 6 additions & 2 deletions setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function setup() {
type: 'confirm',
name: 'addOtherGithubUsernames',
message: 'Would you like to track public repos from specific Github users?',
default: true,
default: false,
when: (answers) => answers.addGithub
},
{
Expand Down Expand Up @@ -83,7 +83,11 @@ source $HOME/.bitcar/completions.sh
};

if (answers.addGithub) {
configContent.sources.push({ type: 'github', host: 'github.com', accessToken: answers.githubAccessToken, usernames: answers.githubUsernames.split(',') });
let githubConfig = { type: 'github', host: 'github.com', accessToken: answers.githubAccessToken };
if (answers.githubUsernames) {
githubConfig.usernames = answers.githubUsernames.split(',');
}
configContent.sources.push(githubConfig);
}

if (answers.addBitbucketServer) {
Expand Down
3 changes: 2 additions & 1 deletion sources/github.com/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function githubSourcePromise(config) {
}
if (githubConfig && githubConfig.usernames) {
resultPromises = resultPromises.concat(getReposFromUsernames(githubConfig));
} else {
}
if (!resultPromises.length) {
return Promise.resolve([]);
}
return Promise.all(resultPromises);
Expand Down

0 comments on commit 65f7baa

Please sign in to comment.