Skip to content

Commit 1352999

Browse files
committed
feat: move to node20, fix __dirname
1 parent e86ad89 commit 1352999

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

__tests__/config.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os from 'os';
22
import path from 'path';
3+
import { fileURLToPath } from 'url';
34

45
import { describe, expect, test } from 'vitest';
56

@@ -18,6 +19,8 @@ interface CustomConfig extends ConfigurationSchema {
1819

1920
describe('configuration loader', () => {
2021
test('overrides and shortstops', async () => {
22+
const __filename = fileURLToPath(import.meta.url);
23+
const __dirname = path.dirname(__filename);
2124
const rootDirectory = path.resolve(__dirname, './fake-serv');
2225
const shortstopHandlers = shortstops({ name: 'fake-serv' }, path.join(rootDirectory, 'src'));
2326
const config = await loadConfiguration<CustomConfig>({

__tests__/fake-serv.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import http from 'http';
22
import path from 'path';
3+
import { fileURLToPath } from 'url';
34

45
import { describe, expect, test } from 'vitest';
56
import request from 'supertest';
@@ -32,6 +33,9 @@ function httpRequest(options: http.RequestOptions) {
3233

3334
describe('fake-serv', () => {
3435
test('basic service functionality', async () => {
36+
const __filename = fileURLToPath(import.meta.url);
37+
const __dirname = path.dirname(__filename);
38+
3539
const options: ServiceStartOptions<FakeServLocals> = {
3640
service,
3741
name: 'fake-serv',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"coconfig": "@openapi-typescript-infra/coconfig"
2525
},
2626
"engines": {
27-
"node": ">=18"
27+
"node": ">=20"
2828
},
2929
"keywords": [
3030
"service",

src/config/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'fs';
22
import path from 'path';
3+
import { fileURLToPath } from 'url';
34

45
import {
56
BaseConfitSchema,
@@ -81,6 +82,9 @@ export async function loadConfiguration<Config extends ConfigurationSchema>({
8182
* if you override this method, you should register your defaults first.
8283
*/
8384
const defaultOrder = dirs.slice(0, dirs.length - 1).reverse();
85+
const __filename = fileURLToPath(import.meta.url);
86+
const __dirname = path.dirname(__filename);
87+
8488
defaultOrder.push(path.join(__dirname, '../..', 'config'));
8589
await defaultOrder.reduce(
8690
(promise, dir) => promise.then(() => addDefaultConfiguration(configFactory, dir, envConfit)),

0 commit comments

Comments
 (0)