diff --git a/TODO.md b/TODO.md index 2bf9df91..29b24181 100644 --- a/TODO.md +++ b/TODO.md @@ -5,3 +5,4 @@ TODO list: - Allow that `config.cwd` to be changed by an argument when using the CLI. Two ways of doing this: - Read a --cwd or similar and change the `config.cwd` to it - Allow any arbitrary `config.*` to be changed with --config.* arguments +- Gracefully remove all created tmp dirs diff --git a/lib/core/config.js b/lib/core/config.js index 58ec4ea5..d918e3ff 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -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;