diff --git a/cli.js b/cli.js index 7ab6916..35c04c3 100644 --- a/cli.js +++ b/cli.js @@ -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' diff --git a/compat/cli.cjs b/compat/cli.cjs deleted file mode 100644 index 5d2ecbc..0000000 --- a/compat/cli.cjs +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env node -'use strict' - -// Must be CommonJS to support Node.js < 12.20 -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) -} - -// Wrapped again to avoid 'Unexpected token import' -require('./import-cli.cjs') diff --git a/compat/import-cli.cjs b/compat/import-cli.cjs deleted file mode 100644 index da57767..0000000 --- a/compat/import-cli.cjs +++ /dev/null @@ -1,6 +0,0 @@ -'use strict' - -import('../cli.js').catch(function (err) { - console.error(err) - process.exit(1) -}) diff --git a/package.json b/package.json index c8e5284..847cd19 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -14,7 +14,6 @@ "files": [ "CHANGELOG.md", "cli.js", - "compat", "index.js", "lint.js", "USAGE" diff --git a/test/dependents.js b/test/dependents.js index 2c62346..82afe93 100644 --- a/test/dependents.js +++ b/test/dependents.js @@ -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')