diff --git a/CHANGES.md b/CHANGES.md index ad63387..05076ea 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,9 @@ Known issues: ## not yet released +- [joyent/node-triton#183] `triton profile create` will no longer use ANSI + codes for styling if stdout isn't a TTY. + ## 5.1.0 - [joyent/node-triton#182] Add `-y, --yes` options to `triton profile create` diff --git a/lib/common.js b/lib/common.js index f438735..fe54f0a 100644 --- a/lib/common.js +++ b/lib/common.js @@ -851,6 +851,18 @@ function ansiStylize(str, color) { } +/* + * Style the given string with ANSI style codes *if stdout is a TTY*. + */ +function ansiStylizeTty(str, color) { + if (!process.stdout.isTTY) { + return str; + } else { + return ansiStylize(str, color); + } +} + + function indent(s, indentation) { if (!indentation) { indentation = ' '; @@ -1096,6 +1108,7 @@ module.exports = { cliSetupTritonApi: cliSetupTritonApi, editInEditor: editInEditor, ansiStylize: ansiStylize, + ansiStylizeTty: ansiStylizeTty, indent: indent, chomp: chomp, generatePassword: generatePassword, diff --git a/lib/do_profile/do_create.js b/lib/do_profile/do_create.js index ca78afe..5a171ed 100644 --- a/lib/do_profile/do_create.js +++ b/lib/do_profile/do_create.js @@ -357,7 +357,7 @@ function _createProfile(opts, cb) { return; } - console.log(common.ansiStylize('\n\n# Docker setup\n', 'bold')); + console.log(common.ansiStylizeTty('\n\n# Docker setup\n', 'bold')); console.log(wrap80('This section will setup authentication to ' + 'Triton DataCenter\'s Docker endpoint using your account ' + 'and key information specified above. This is only required ' +