From 099806cef634b75d829b5dcc68e9d40ec8c4391e Mon Sep 17 00:00:00 2001 From: Ryan Poole Date: Fri, 5 Apr 2024 19:21:27 +0100 Subject: [PATCH] Support for node 18. Fixes #140 #141 --- .github/workflows/test.yml | 6 +++++- src/ConfigTasks.ts | 3 ++- src/EnumTasks.ts | 4 ++-- tsconfig.json | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ca2506..b245aaa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,11 +10,15 @@ on: jobs: run-tests: runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] + steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: ${{ matrix.node-version }} - run: npm install - run: npm run test \ No newline at end of file diff --git a/src/ConfigTasks.ts b/src/ConfigTasks.ts index 8ee224b..c9d7c88 100644 --- a/src/ConfigTasks.ts +++ b/src/ConfigTasks.ts @@ -1,5 +1,6 @@ import * as path from 'path' import { Config } from './Typings.js' +import { fileURLToPath } from 'url' /** * Applies configuration defaults to a given configuration object. @@ -24,7 +25,7 @@ export function applyConfigDefaults(config: Config): Config { schemaAsNamespace: false, typeOverrides: {}, typeMap: {}, - template: path.join(import.meta.dirname, './template.handlebars'), + template: path.join(path.dirname(fileURLToPath(import.meta.url)), './template.handlebars'), custom: {} } return Object.assign(defaultConfig, config) diff --git a/src/EnumTasks.ts b/src/EnumTasks.ts index 2dbda79..4e300b5 100644 --- a/src/EnumTasks.ts +++ b/src/EnumTasks.ts @@ -7,12 +7,12 @@ import * as SchemaTasks from './SchemaTasks.js' export async function getAllEnums(db: Knex, config: Config): Promise { const adapter = AdapterFactory.buildAdapter(db.client.dialect) return (await adapter.getAllEnums(db, config)) - .toSorted((a, b) => a.name.localeCompare(b.name)) + .sort((a, b) => a.name.localeCompare(b.name)) .map(e => ({ name: e.name, schema: SchemaTasks.generateSchemaName(e.schema), convertedName: generateEnumName(e.name, config), - values: Object.keys(e.values).toSorted((a, b) => a.localeCompare(b)).map(ee => ({ + values: Object.keys(e.values).sort((a, b) => a.localeCompare(b)).map(ee => ({ originalKey: ee, convertedKey: generateEnumKey(ee, config), value: e.values[ee] diff --git a/tsconfig.json b/tsconfig.json index 52e8edc..92254c2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "src/**/*.spec.*" ], "compilerOptions": { - "target": "ESNext", + "target": "ES2022", "declaration": true, "module": "NodeNext", "moduleResolution": "NodeNext",