Better error messages for invalid bowerrc files, closes #220.

This commit is contained in:
André Cruz
2013-01-29 15:07:25 +00:00
parent 01bd65f8e6
commit a8c72398ba

View File

@@ -23,19 +23,28 @@ var folder = process.platform === 'win32'
: '.bower';
// Bower Config
var config = require('rc') ('bower', {
cache : path.join(roaming, folder, 'cache'),
links : path.join(roaming, folder, 'links'),
completion : path.join(roaming, folder, 'completion'),
json : 'component.json',
endpoint : 'https://bower.herokuapp.com',
directory : 'components'
});
var config;
try {
config = require('rc') ('bower', {
cache : path.join(roaming, folder, 'cache'),
links : path.join(roaming, folder, 'links'),
completion : path.join(roaming, folder, 'completion'),
json : 'component.json',
endpoint : 'https://bower.herokuapp.com',
directory : 'components'
});
} catch (e) {
throw new Error('Unable to parse global .bowerrc file: ' + e.message);
}
// If there is a local .bowerrc file, merge it
var localFile = path.join(this.cwd, '.bowerrc');
if (fileExists(localFile)) {
_.extend(config, JSON.parse(fs.readFileSync(localFile)));
try {
_.extend(config, JSON.parse(fs.readFileSync(localFile)));
} catch (e) {
throw new Error('Unable to parse local .bowerrc file: ' + e.message);
}
}
// Configure tmp package to use graceful degradationn