Skip to content

Commit

Permalink
fix: tests, remove old dependencies (#103)
Browse files Browse the repository at this point in the history
* fix: tests, remove old dependencies

* chore: update gh action

* chore: update publish

* chore: use pnpm cache
  • Loading branch information
kevinchappell authored May 28, 2024
1 parent d7bb11f commit 9fef561
Show file tree
Hide file tree
Showing 10 changed files with 3,649 additions and 18,025 deletions.
17 changes: 0 additions & 17 deletions .eslintrc.js

This file was deleted.

15 changes: 10 additions & 5 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ on:

jobs:
build:
env:
CI: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: 'pnpm'
- name: Install dependencies
env:
CI: true
run: npm install
run: pnpm install
- name: Test
run: npm test
run: pnpm test
- name: Publish
if: success()
env:
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ name: Pull Request

jobs:
test:
env:
CI: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: 'pnpm'
- name: Install dependencies
env:
CI: true
run: npm ci
run: pnpm install
- name: Test
run: npm test
run: pnpm test
37 changes: 37 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"organizeImports": {
"enabled": true
},
"vcs": {
"clientKind": "git",
"enabled": true,
"useIgnoreFile": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": false
}
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 120
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded"
}
},
"json": {
"formatter": {
"indentStyle": "space"
}
}
}
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const { default: mi18n } = require('mi18n')

const langFiles = fs.readdirSync(__dirname).reduce((acc, lang) => {
Expand All @@ -8,7 +8,7 @@ const langFiles = fs.readdirSync(__dirname).reduce((acc, lang) => {
}
const langFile = fs.readFileSync(path.resolve(__dirname, lang)).toString()
const fileName = path.basename(lang)
const locale = fileName.substr(0, fileName.indexOf('.'))
const locale = fileName.substring(0, fileName.indexOf('.'))
acc[locale] = mi18n.processFile(langFile)
return acc
}, {})
Expand Down
25 changes: 25 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { test } = require('node:test')
const assert = require('node:assert')
const { glob } = require('node:fs')

const langFiles = require('./index')

glob('*.lang', (err, matches) => {
if (err) {
console.error(err)
return
}
const localeCount = matches.length

test(`should contain ${localeCount} languages`, () => {
assert.equal(Object.keys(langFiles).length, localeCount)
})

test('should contain specific languages', () => {
const expectedLocales = matches.map((lang) => lang.substring(0, lang.indexOf('.')))

for (const lang of expectedLocales) {
assert.equal(Object.hasOwn(langFiles, lang), true)
}
})
})
Loading

0 comments on commit 9fef561

Please sign in to comment.