Config improv.

This commit is contained in:
André Cruz
2013-04-06 12:30:27 +01:00
parent 408417bbda
commit 201bf29429
2 changed files with 22 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
var path = require('path');
var fs = require('fs');
var mout = require('mout');
var tmp = require('tmp');
var mkdirp = require('mkdirp');
// Guess some needed properties based on the user OS
var temp = process.env.TMPDIR
@@ -26,6 +26,8 @@ var proxy = process.env.HTTPS_PROXY
|| process.env.HTTP_PROXY
|| process.env.http_proxy;
// -----------
// Setup bower config
var config;
try {
@@ -51,8 +53,23 @@ try {
}
} catch (e) {}
// Configure tmp package to use graceful degradation
// If an uncaught exception occurs, the temporary directories will be deleted nevertheless
tmp.setGracefulCleanup();
// Add aliases that is meant to be used internally
mout.object.mixIn(config, {
cache: path.join(config.roaming, 'cache'),
links: path.join(config.roaming, 'links'),
completion: path.join(config.roaming, 'completion'),
gitTemplate: path.join(config.roaming, 'git_template')
});
// -----------
// Make sure that we have our git template directory
// The git template directory is an empty dir that will be set up for every git command
// So that the user git hooks won't be used
try {
mkdirp.sync(config.gitTemplate);
} catch (e) {
throw new Error('Unable to create git_template directory: ' + e.message);
}
module.exports = config;