Skip to content

Commit

Permalink
Drops support for Node < 14.14.0 & migrates tests to ESM on src file
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Jun 11, 2023
1 parent 275976a commit 28a0cc5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest']
node: ['12.2.0']
node: ['14.14.0']
name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -43,7 +43,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest']
node: ['12.2.0', '14.0', '16.0', '18.0']
node: ['14.14.0', '16.0', '18.0']
name: Testing Node ${{ matrix.node }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test/fixtures/**
.nyc_output/**
coverage/*
package-lock.json
lib
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}
},
"engines": {
"node": ">=12.2.0"
"node": ">=14.14.0"
},
"publishConfig": {
"access": "public"
Expand Down
34 changes: 20 additions & 14 deletions test/index.cjs → test/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/* eslint-env node, mocha */

const assert = require('assert')
const Metalsmith = require('metalsmith')
const metadata = require('..')
const { name } = require('../package.json')
import assert from 'node:assert'
import { resolve, dirname } from 'node:path'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import Metalsmith from 'metalsmith'
import metadata from '../src/index.js'

const __dirname = dirname(fileURLToPath(import.meta.url))
const { name } = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8'))

describe('@metalsmith/metadata', function () {
it('should export a named plugin function matching package.json name', function () {
Expand Down Expand Up @@ -270,16 +275,17 @@ describe('Error handling', function () {
it('should error when TOML is not installed', function (done) {
// run this test locally by removing this.skip & running "npm remove toml"
this.skip()
const Metalsmith = require('metalsmith')
Metalsmith('test/fixtures/toml')
.env('DEBUG', process.env.DEBUG)
.use(metadata({ file: 'src/data.toml' }))
.build(function (err) {
if (!err) done(new Error('No error was thrown'))
assert(err)
assert(err.message.startsWith('To use toml you must install it first'))
done()
})
const Metalsmith = import('metalsmith').then(() => {
Metalsmith('test/fixtures/toml')
.env('DEBUG', process.env.DEBUG)
.use(metadata({ file: 'src/data.toml' }))
.build(function (err) {
if (!err) done(new Error('No error was thrown'))
assert(err)
assert(err.message.startsWith('To use toml you must install it first'))
done()
})
})
})

it('should error for malformed data', function (done) {
Expand Down

0 comments on commit 28a0cc5

Please sign in to comment.