From 7c74877b72a07329bad788ca5a060bacfa176aa2 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 9 Dec 2017 19:38:20 -0200 Subject: [PATCH 1/5] assert: improve error messages From now on all error messages produced by `assert` in strict mode will produce a error diff. --- doc/api/assert.md | 33 ++++++++ lib/assert.js | 16 +++- lib/internal/errors.js | 150 ++++++++++++++++++++++++++++++++++- test/parallel/test-assert.js | 143 ++++++++++++++++++++++++++++++++- 4 files changed, 332 insertions(+), 10 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index c3735440932e25..3a69273935bec2 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -17,6 +17,9 @@ For more information about the used equality comparisons see + +* `env` {object} A object containing the environment variables to check. + Defaults to `process.env`. +* Returns: {number} + +Returns: +* 1 for 2, +* 4 for 16, +* 8 for 256, +* 24 for 16,777,216 +colors supported. + +Use this to determine what colors the terminal supports. Due to the nature of +colors in terminals it is possible to either have false positives or false +negatives. It depends on process information and the environment variables that +may lie about what terminal is used. +To enforce a specific behavior without relying on `process.env` it is possible +to pass in an object with different settings. + +Use the `NODE_DISABLE_COLORS` environment variable to enforce this function to +always return 1. + ## tty.isatty(fd)