Skip to content

Commit 229ae47

Browse files
committed
Change to simplify color detection
1 parent a0f4571 commit 229ae47

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

color-browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = false

color.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = true

index.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
'use strict'
22

33
var isEmpty = require('is-empty')
4-
5-
// Detect color support.
6-
var color = true
7-
8-
try {
9-
color = 'inspect' in require('util')
10-
} catch (_) {
11-
/* istanbul ignore next - browser */
12-
color = false
13-
}
4+
var color = require('./color')
145

156
module.exports = color ? inspect : /* istanbul ignore next */ noColor
167

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@
2525
],
2626
"files": [
2727
"index.js",
28+
"color.js",
29+
"color-browser.js",
2830
"types/index.d.ts"
2931
],
32+
"browser": {
33+
"./color.js": "./color-browser.js"
34+
},
35+
"react-native": {
36+
"./color.js": "./color-browser.js"
37+
},
3038
"types": "types/index.d.ts",
3139
"dependencies": {
3240
"is-empty": "^1.0.0"
@@ -48,8 +56,8 @@
4856
},
4957
"scripts": {
5058
"format": "remark . -qfo && prettier --write \"**/*.{js,ts}\" && xo --fix",
51-
"build-bundle": "browserify . --bare -s unistUtilInspect > unist-util-inspect.js",
52-
"build-mangle": "browserify . --bare -s unistUtilInspect -p tinyify > unist-util-inspect.min.js",
59+
"build-bundle": "browserify . -s unistUtilInspect > unist-util-inspect.js",
60+
"build-mangle": "browserify . -s unistUtilInspect -p tinyify > unist-util-inspect.min.js",
5361
"build": "npm run build-bundle && npm run build-mangle",
5462
"test-api": "node test",
5563
"test-coverage": "nyc --reporter lcov tape test.js",

0 commit comments

Comments
 (0)