From 233e8ee784e37d0f72bc9e0ece0c0f134d07ffc3 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 31 Aug 2015 11:16:56 -0700 Subject: [PATCH] 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) ... --- lib/cli.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 259e702..14f768e 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -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.