Skip to content

Commit 2a76925

Browse files
authored
Merge pull request #405 from toddbluhm/feat-update-node-versions
Remove Nodejs 18 & <20.10 support, add Nodejs 24.x support.
2 parents a08ac87 + 67f29fc commit 2a76925

File tree

13 files changed

+15
-41
lines changed

13 files changed

+15
-41
lines changed

.github/workflows/linux-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [18.x, 20.x, 22.x]
14+
node-version: [20.10.0, 20.x, 22.x, 24.x]
1515

1616
steps:
1717
- name: Checkout Project

.github/workflows/windows-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [18.x, 20.x, 22.x]
15+
node-version: [20.10.0, 20.x, 22.x, 24.x]
1616

1717
steps:
1818
- name: Checkout Project

dist/parse-args.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { createRequire } from 'node:module';
21
import { Command } from '@commander-js/extra-typings';
32
import { parseArgList } from './utils.js';
4-
// TODO: once we drop support for node <v20.10, this can be converted to
5-
// a normal import statement
6-
const packageJson = createRequire(import.meta.url)('../package.json');
3+
import packageJson from '../package.json' with { type: 'json' };
74
/**
85
* Parses the arguments passed into the cli
96
*/

dist/parse-env-file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync, readFileSync } from 'node:fs';
22
import { extname } from 'node:path';
33
import { pathToFileURL } from 'node:url';
4-
import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise, importAttributesKeyword } from './utils.js';
4+
import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise } from './utils.js';
55
/**
66
* Gets the environment vars from an env file
77
*/
@@ -19,7 +19,7 @@ export async function getEnvFileVars(envFilePath) {
1919
// For some reason in ES Modules, only JSON file types need to be specifically delinated when importing them
2020
let attributeTypes = {};
2121
if (ext === '.json') {
22-
attributeTypes = { [importAttributesKeyword]: { type: 'json' } };
22+
attributeTypes = { with: { type: 'json' } };
2323
}
2424
const res = await import(pathToFileURL(absolutePath).href, attributeTypes);
2525
if (typeof res === 'object' && res && 'default' in res) {

dist/parse-rc-file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { stat, readFile } from 'node:fs';
22
import { promisify } from 'node:util';
33
import { extname } from 'node:path';
44
import { pathToFileURL } from 'node:url';
5-
import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise, importAttributesKeyword } from './utils.js';
5+
import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise } from './utils.js';
66
const statAsync = promisify(stat);
77
const readFileAsync = promisify(readFile);
88
/**
@@ -26,7 +26,7 @@ export async function getRCFileVars({ environments, filePath }) {
2626
// For some reason in ES Modules, only JSON file types need to be specifically delinated when importing them
2727
let attributeTypes = {};
2828
if (ext === '.json') {
29-
attributeTypes = { [importAttributesKeyword]: { type: 'json' } };
29+
attributeTypes = { with: { type: 'json' } };
3030
}
3131
const res = await import(pathToFileURL(absolutePath).href, attributeTypes);
3232
if ('default' in res) {

dist/utils.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ export declare function parseArgList(list: string): string[];
1111
* A simple function to test if the value is a promise/thenable
1212
*/
1313
export declare function isPromise<T>(value?: T | PromiseLike<T>): value is PromiseLike<T>;
14-
export declare const importAttributesKeyword: string;

dist/utils.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,3 @@ export function isPromise(value) {
2929
&& 'then' in value
3030
&& typeof value.then === 'function';
3131
}
32-
// "Import Attributes" are only supported since node v18.20 and v20.10.
33-
// For older node versions, we have to use "Import Assertions".
34-
// TODO: remove this check when we drop support for node v20
35-
const [major, minor] = process.version.slice(1).split('.').map(Number);
36-
const legacyImportAssertions = (major === 18 && minor < 20) || (major === 20 && minor < 10);
37-
export const importAttributesKeyword = legacyImportAssertions ? 'assert' : 'with';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"types": "dist/index.d.ts",
77
"type": "module",
88
"engines": {
9-
"node": ">=18.0.0"
9+
"node": ">=20.10.0"
1010
},
1111
"bin": {
1212
"env-cmd": "bin/env-cmd.js"

src/parse-args.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import { createRequire } from 'node:module'
21
import { Command } from '@commander-js/extra-typings'
32
import type { EnvCmdOptions, CommanderOptions, EnvFileOptions, RCFileOptions } from './types.ts'
43
import { parseArgList } from './utils.js'
5-
6-
// TODO: once we drop support for node <v20.10, this can be converted to
7-
// a normal import statement
8-
const packageJson = createRequire(import.meta.url)('../package.json') as {
9-
version: string;
10-
}
4+
import packageJson from '../package.json' with { type: 'json' }
115

126
/**
137
* Parses the arguments passed into the cli

src/parse-env-file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync, readFileSync } from 'node:fs'
22
import { extname } from 'node:path'
33
import { pathToFileURL } from 'node:url'
4-
import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise, importAttributesKeyword } from './utils.js'
4+
import { resolveEnvFilePath, IMPORT_HOOK_EXTENSIONS, isPromise } from './utils.js'
55
import type { Environment } from './types.ts'
66

77
/**
@@ -22,7 +22,7 @@ export async function getEnvFileVars(envFilePath: string): Promise<Environment>
2222
// For some reason in ES Modules, only JSON file types need to be specifically delinated when importing them
2323
let attributeTypes = {}
2424
if (ext === '.json') {
25-
attributeTypes = { [importAttributesKeyword]: { type: 'json' } }
25+
attributeTypes = { with: { type: 'json' } }
2626
}
2727
const res: unknown = await import(pathToFileURL(absolutePath).href, attributeTypes)
2828
if (typeof res === 'object' && res && 'default' in res) {

0 commit comments

Comments
 (0)