reduce mkdir noise in log for every 'triton ...' run

E.g.:
    $ triton -v inst 1c7f40f6-a253-49f3-94d6-8f0656440696 2>&1 | bunyan
    [2015-08-31T17:57:02.682Z]  INFO: triton/24726 on danger0.local (/Users/trentm/joy/node-triton/lib/cli.js:188): failed to make dir /Users/trentm/.triton (err.code=EEXIST)
        Error: EEXIST, file already exists '/Users/trentm/.triton'
            at Object.fs.mkdirSync (fs.js:654:18)
            at /Users/trentm/joy/node-triton/lib/cli.js:186:24
            at Array.forEach (native)
            at CLI.triton (/Users/trentm/joy/node-triton/lib/cli.js:184:29)
            at CLI.do_instance (/Users/trentm/joy/node-triton/lib/do_instance.js:16:9)
            at CLI.dispatch (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:664:13)
            at /Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:425:18
            at CLI.init (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:477:5)
            at CLI.init (/Users/trentm/joy/node-triton/lib/cli.js:221:26)
            at CLI.main (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:404:10)
    [2015-08-31T17:57:02.684Z]  INFO: triton/24726 on danger0.local (/Users/trentm/joy/node-triton/lib/cli.js:188): failed to make dir /Users/trentm/.triton/cache (err.code=EEXIST)
        Error: EEXIST, file already exists '/Users/trentm/.triton/cache'
            at Object.fs.mkdirSync (fs.js:654:18)
            at /Users/trentm/joy/node-triton/lib/cli.js:186:24
            at Array.forEach (native)
            at CLI.triton (/Users/trentm/joy/node-triton/lib/cli.js:184:29)
            at CLI.do_instance (/Users/trentm/joy/node-triton/lib/do_instance.js:16:9)
            at CLI.dispatch (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:664:13)
            at /Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:425:18
            at CLI.init (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:477:5)
            at CLI.init (/Users/trentm/joy/node-triton/lib/cli.js:221:26)
            at CLI.main (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:404:10)
    ...
This commit is contained in:
Trent Mick 2015-08-31 11:16:56 -07:00
parent 786ec9771c
commit 233e8ee784
1 changed files with 4 additions and 4 deletions

View File

@ -181,13 +181,13 @@ CLI.prototype.init = function (opts, args, callback) {
var dir = path.dirname(userConfigPath);
var cacheDir = path.join(dir, 'cache');
[dir, cacheDir].forEach(function (d) {
if (!fs.existsSync(cacheDir)) {
try {
fs.mkdirSync(d);
fs.mkdirSync(cacheDir);
} catch (e) {
log.info({err: e}, 'failed to make dir %s', d);
log.info({err: e}, 'failed to make dir %s', cacheDir);
}
});
}
// XXX support keyId being a priv or pub key path, a la imgapi-cli
// XXX Add TRITON_* envvars.