diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index 5a5c6d0..4240bf0 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x, 22.x] + node-version: [20.x, 22.x, 24.x] steps: - name: Checkout Project diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index 574e919..13b28d0 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x, 22.x] + node-version: [20.x, 22.x, 24.x] steps: - name: Checkout Project diff --git a/dist/parse-args.js b/dist/parse-args.js index 1af336a..c269122 100644 --- a/dist/parse-args.js +++ b/dist/parse-args.js @@ -1,9 +1,6 @@ -import { createRequire } from 'node:module'; import { Command } from '@commander-js/extra-typings'; import { parseArgList } from './utils.js'; -// TODO: once we drop support for node (value?: T | PromiseLike): value is PromiseLike; -export declare const importAttributesKeyword: string; diff --git a/dist/utils.js b/dist/utils.js index 649629d..7535a34 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -29,9 +29,3 @@ export function isPromise(value) { && 'then' in value && typeof value.then === 'function'; } -// "Import Attributes" are only supported since node v18.20 and v20.10. -// For older node versions, we have to use "Import Assertions". -// TODO: remove this check when we drop support for node v20 -const [major, minor] = process.version.slice(1).split('.').map(Number); -const legacyImportAssertions = (major === 18 && minor < 20) || (major === 20 && minor < 10); -export const importAttributesKeyword = legacyImportAssertions ? 'assert' : 'with'; diff --git a/package.json b/package.json index bc9bdd8..4e203b2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "types": "dist/index.d.ts", "type": "module", "engines": { - "node": ">=18.0.0" + "node": ">=20.10.0" }, "bin": { "env-cmd": "bin/env-cmd.js" diff --git a/src/parse-args.ts b/src/parse-args.ts index 03fbad4..ff39601 100644 --- a/src/parse-args.ts +++ b/src/parse-args.ts @@ -1,13 +1,7 @@ -import { createRequire } from 'node:module' import { Command } from '@commander-js/extra-typings' import type { EnvCmdOptions, CommanderOptions, EnvFileOptions, RCFileOptions } from './types.ts' import { parseArgList } from './utils.js' - -// TODO: once we drop support for node // For some reason in ES Modules, only JSON file types need to be specifically delinated when importing them let attributeTypes = {} if (ext === '.json') { - attributeTypes = { [importAttributesKeyword]: { type: 'json' } } + attributeTypes = { with: { type: 'json' } } } const res: unknown = await import(pathToFileURL(absolutePath).href, attributeTypes) if (typeof res === 'object' && res && 'default' in res) { diff --git a/src/parse-rc-file.ts b/src/parse-rc-file.ts index f4bfa14..09ea9dd 100644 --- a/src/parse-rc-file.ts +++ b/src/parse-rc-file.ts @@ -2,7 +2,7 @@ import { stat, readFile } from 'node:fs' import { promisify } from 'node:util' import { extname } from 'node:path' import { pathToFileURL } from 'node:url' -import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise, importAttributesKeyword } from './utils.js' +import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise } from './utils.js' import type { Environment, RCEnvironment } from './types.ts' const statAsync = promisify(stat) @@ -33,7 +33,7 @@ export async function getRCFileVars( // For some reason in ES Modules, only JSON file types need to be specifically delinated when importing them let attributeTypes = {} if (ext === '.json') { - attributeTypes = { [importAttributesKeyword]: { type: 'json' } } + attributeTypes = { with: { type: 'json' } } } const res = await import(pathToFileURL(absolutePath).href, attributeTypes) as RCEnvironment | { default: RCEnvironment } if ('default' in res) { diff --git a/src/utils.ts b/src/utils.ts index 2b005c1..466c483 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -32,13 +32,3 @@ export function isPromise(value?: T | PromiseLike): value is PromiseLike