Skip to content

Commit

Permalink
Change to use export map
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 5, 2023
1 parent c5a927c commit 002ffa4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.DS_Store
lib/color.browser.d.ts
lib/color.d.ts
lib/index.d.ts
test.d.ts
*.d.ts
*.log
coverage/
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion lib/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* @returns {string}
*/
export function color(d) {
return '\u001B[33m' + d + '\u001B[39m'
return d
}
2 changes: 1 addition & 1 deletion lib/color.browser.js → lib/color.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* @returns {string}
*/
export function color(d) {
return d
return '\u001B[33m' + d + '\u001B[39m'
}
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
*/

import {convert} from 'unist-util-is'
import {color} from './color.js'
import {color} from 'unist-util-visit-parents/do-not-use-color'

/** @type {Readonly<ActionTuple>} */
const empty = []
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"browser": {
"./lib/color.js": "./lib/color.browser.js"
},
"react-native": {
"./lib/color.js": "./lib/color.browser.js"
"exports": {
".": "./index.js",
"./do-not-use-color": {
"node": "./lib/color.node.js",
"default": "./lib/color.js"
}
},
"types": "index.d.ts",
"files": [
Expand Down
13 changes: 5 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @typedef {import('hast').Root} HastRoot
* @typedef {import('mdast').PhrasingContent} PhrasingContent
* @typedef {import('unist').Parent} Parent
* @typedef {import('xast').Element} XastElement
* @typedef {import('xast').Root} XastRoot
*/

Expand All @@ -12,7 +11,7 @@ import stripAnsi from 'strip-ansi'
import {fromMarkdown} from 'mdast-util-from-markdown'
import {gfmFromMarkdown} from 'mdast-util-gfm'
import {gfm} from 'micromark-extension-gfm'
import {visitParents, EXIT, SKIP, CONTINUE} from './index.js'
import {EXIT, SKIP, CONTINUE, visitParents} from 'unist-util-visit-parents'

const tree = fromMarkdown('Some _emphasis_, **importance**, and `code`.')
const paragraph = tree.children[0]
Expand Down Expand Up @@ -85,12 +84,10 @@ const textAncestors = [

test('visitParents', async function (t) {
await t.test('should expose the public api', async function () {
assert.deepEqual(Object.keys(await import('./index.js')).sort(), [
'CONTINUE',
'EXIT',
'SKIP',
'visitParents'
])
assert.deepEqual(
Object.keys(await import('unist-util-visit-parents')).sort(),
['CONTINUE', 'EXIT', 'SKIP', 'visitParents']
)
})

await t.test('should fail without tree', async function () {
Expand Down

0 comments on commit 002ffa4

Please sign in to comment.