Skip to content

Commit

Permalink
Remove CJS compatibility hack for Node.js < 12.20
Browse files Browse the repository at this point in the history
Which had a startup cost.

Category: removal
  • Loading branch information
vweevers committed Apr 6, 2024
1 parent 50f0eca commit 08c2475
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
6 changes: 6 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env node

if (process.version.match(/^v(\d+)\./)[1] < 14) {
// Return silently to support hallmark in 'npm test'
console.error('Skipping hallmark: Node 14 or greater is required.')
process.exit(0)
}

import subarg from 'subarg'
import fs from 'node:fs'
import * as hallmark from './index.js'
Expand Down
12 changes: 0 additions & 12 deletions compat/cli.cjs

This file was deleted.

6 changes: 0 additions & 6 deletions compat/import-cli.cjs

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Markdown Style Guide, with linter and automatic fixer",
"author": "Vincent Weevers",
"license": "GPL-3.0",
"bin": "compat/cli.cjs",
"bin": "cli.js",
"type": "module",
"exports": "./index.js",
"scripts": {
Expand All @@ -14,7 +14,6 @@
"files": [
"CHANGELOG.md",
"cli.js",
"compat",
"index.js",
"lint.js",
"USAGE"
Expand Down
2 changes: 1 addition & 1 deletion test/dependents.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ for (const repo of dependents) {

// Pipe stdout to stderr because our stdout is for TAP
const stdio = ['ignore', process.stderr, process.stderr, 'ipc']
const cli = path.resolve(__dirname, '..', 'compat', 'cli.cjs')
const cli = path.resolve(__dirname, '..', 'cli.js')

cp.fork(cli, { cwd, stdio }).on('exit', function (code) {
t.is(code, 0, 'hallmark linter exited with code 0')
Expand Down

0 comments on commit 08c2475

Please sign in to comment.