| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0197ea4 commit 524b230
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -473,7 +473,8 @@ function stylizeWithColor(str, styleType) { | |||
| 473 | 473 | const style = inspect.styles[styleType]; | |
| 474 | 474 | if (style !== undefined) { | |
| 475 | 475 | const color = inspect.colors[style]; | |
| 476 | - return `\u001b[${color[0]}m${str}\u001b[${color[1]}m`; | ||
| 476 | + if (color !== undefined) | ||
| 477 | + return `\u001b[${color[0]}m${str}\u001b[${color[1]}m`; | ||
| 477 | 478 | } | |
| 478 | 479 | return str; | |
| 479 | 480 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2240,6 +2240,12 @@ assert.strictEqual( | |||
| 2240 | 2240 | assert.deepStrictEqual(inspect.colors[bgColor], [40 + i, 49]); | |
| 2241 | 2241 | assert.deepStrictEqual(inspect.colors[`${bgColor}Bright`], [100 + i, 49]); | |
| 2242 | 2242 | }); | |
| 2243 | + | ||
| 2244 | + // Unknown colors are handled gracefully: | ||
| 2245 | + const stringStyle = inspect.styles.string; | ||
| 2246 | + inspect.styles.string = 'UNKNOWN'; | ||
| 2247 | + assert.strictEqual(inspect('foobar', { colors: true }), "'foobar'"); | ||
| 2248 | + inspect.styles.string = stringStyle; | ||
| 2243 | 2249 | } | |
| 2244 | 2250 | ||
| 2245 | 2251 | assert.strictEqual( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments