Created
November 12, 2014 03:55
-
-
Save tizzo/1bbf8b176cbe438b17d8 to your computer and use it in GitHub Desktop.
Node.js Enable/disable colors based on process.itTTY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env node | |
var prettyjson = require('prettyjson'); | |
var someDataStructure = { | |
firstLevelA: { | |
secondLevel1: { | |
thirdLevelA: 'foo', | |
thirdLevelB: [] | |
} | |
}, | |
firstLevelB: {}, | |
firstLevelC: {} | |
}; | |
console.log(prettyjson.render(someDataStructure, {noColor: !process.stdout.isTTY})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "pty-example", | |
"version": "0.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"prettyjson": "^1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment