diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f174caa..67a9ae5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare + - run: pnpm build - run: pnpm lint name: Lint diff --git a/.github/workflows/test-cjs.yml b/.github/workflows/test-cjs.yml new file mode 100644 index 0000000..9348c04 --- /dev/null +++ b/.github/workflows/test-cjs.yml @@ -0,0 +1,16 @@ +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/prepare + - run: pnpm build + - run: pnpm run test:cjs + +name: Test CommonJS + +on: + pull_request: ~ + push: + branches: + - main diff --git a/package.json b/package.json index 9b89c9c..8bf5815 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,10 @@ "type": "module", "exports": { ".": { + "types": { + "import": "./lib/index.d.ts", + "require": "./lib/index.d.cts" + }, "import": "./lib/index.js", "require": "./lib/index.cjs" } @@ -52,14 +56,15 @@ "prepare": "husky install", "should-semantic-release": "should-semantic-release --verbose", "test": "vitest", + "test:cjs": "node ./src/e2e.cjs", "tsc": "tsc" }, "lint-staged": { "*": "prettier --ignore-unknown --write" }, "dependencies": { - "@sindresorhus/is": "^6.0.0", - "char-regex": "^2.0.0", + "@sindresorhus/is": "^4.6.0", + "char-regex": "^1.0.2", "emojilib": "^2.4.0", "skin-tone": "^2.0.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 39497b3..1aa128b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,11 +6,11 @@ settings: dependencies: '@sindresorhus/is': - specifier: ^6.0.0 - version: 6.0.0 + specifier: ^4.6.0 + version: 4.6.0 char-regex: - specifier: ^2.0.0 - version: 2.0.1 + specifier: ^1.0.2 + version: 1.0.2 emojilib: specifier: ^2.4.0 version: 2.4.0 @@ -1434,16 +1434,16 @@ packages: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true + /@sindresorhus/is@4.6.0: + resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} + engines: {node: '>=10'} + dev: false + /@sindresorhus/is@5.3.0: resolution: {integrity: sha512-CX6t4SYQ37lzxicAqsBtxA3OseeoVrh9cSJ5PFYam0GksYlupRfy1A+Q4aYD3zvcfECLc0zO2u+ZnR2UYKvCrw==} engines: {node: '>=14.16'} dev: true - /@sindresorhus/is@6.0.0: - resolution: {integrity: sha512-iVkg+3V+GJfof7yAHOxHyoiEfgpRJhnddOY3EsTM/uqwcm6M/jDQwK1n1nnraMpTRT36CxS0RCtJohggaQ0jgQ==} - engines: {node: '>=16'} - dev: false - /@sindresorhus/merge-streams@1.0.0: resolution: {integrity: sha512-rUV5WyJrJLoloD4NDN1V1+LDMDWOa4OTsT4yYJwQNpTU6FWxkxHpL7eu4w+DmiH8x/EAM1otkPE1+LaspIbplw==} engines: {node: '>=18'} @@ -2313,9 +2313,9 @@ packages: engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} dev: true - /char-regex@2.0.1: - resolution: {integrity: sha512-oSvEeo6ZUD7NepqAat3RqoucZ5SeqLJgOvVIwkafu6IP3V0pO38s/ypdVUmDDK6qIIHNlYHJAKX9E7R7HoKElw==} - engines: {node: '>=12.20'} + /char-regex@1.0.2: + resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} + engines: {node: '>=10'} dev: false /character-entities-legacy@1.1.4: diff --git a/src/e2e.cjs b/src/e2e.cjs new file mode 100644 index 0000000..e35c73f --- /dev/null +++ b/src/e2e.cjs @@ -0,0 +1,5 @@ +const { strict: assert } = require('node:assert') + +const emoji = require('../lib/index.cjs') + +assert.equal(emoji.emojify(':wave:'), '👋') diff --git a/src/emojify.ts b/src/emojify.ts index d21107d..e1d41eb 100644 --- a/src/emojify.ts +++ b/src/emojify.ts @@ -1,4 +1,4 @@ -import { assert, default as is } from '@sindresorhus/is' +import is from '@sindresorhus/is' import { findByName } from './findByName.js' import { asFunction, normalizeName } from './utils.js' @@ -21,9 +21,9 @@ export const emojify = ( const fallbackFunction = fallback === undefined ? fallback : asFunction(fallback) - assert.string(input) - assert.any([is.undefined, is.function], fallbackFunction) - assert.function(format) + is.assert.string(input) + is.assert.any([is.default.undefined, is.default.function_], fallbackFunction) + is.assert.function_(format) return input.replace(/:[\w\-+]+:/g, part => { const found = findByName(part) diff --git a/src/replace.ts b/src/replace.ts index 663258b..5ea5966 100644 --- a/src/replace.ts +++ b/src/replace.ts @@ -18,7 +18,7 @@ export const replace = ( const replace = asFunction(replacement) assert.string(input) - assert.function(replace) + assert.function_(replace) assert.boolean(preserveSpaces) const characters = input.match(charRegexMatcher) diff --git a/vitest.config.ts b/vitest.config.ts index d209a18..6a43cb1 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,7 +6,7 @@ export default defineConfig({ coverage: { all: true, branches: 100, - exclude: ['lib', 'src/*.d.ts', 'src/index.ts'], + exclude: ['lib', 'src/*.d.ts', 'src/e2e.cjs', 'src/index.ts'], functions: 100, include: ['src'], lines: 100,