From eb481215e3c3df28bdba9392d17e460a293f43c6 Mon Sep 17 00:00:00 2001 From: DetachHead Date: Sat, 3 Jul 2021 15:46:51 +1000 Subject: [PATCH 1/2] compile as part of the test script since ts-node doesn't typecheck everything --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f8b69b9..8e32b08 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Server that holds the SponsorBlock database", "main": "src/index.ts", "scripts": { - "test": "ts-node test/test.ts", + "test": "npm run tsc && ts-node test/test.ts", "dev": "nodemon", "dev:bash": "nodemon -x 'npm test ; npm start'", "start": "ts-node src/index.ts", From 81c2e7b059122d6db642bc3fc45e2e6ab4b9288d Mon Sep 17 00:00:00 2001 From: DetachHead Date: Sat, 3 Jul 2021 15:53:59 +1000 Subject: [PATCH 2/2] read test script value from package.json --- src/config.ts | 3 ++- tsconfig.json | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index fca30c6..5a5ad8c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,7 +1,8 @@ import fs from 'fs'; import {SBSConfig} from "./types/config.model"; +import packageJson from "../package.json" -const isTestMode = process.env.npm_lifecycle_script === 'ts-node test/test.ts'; +const isTestMode = process.env.npm_lifecycle_script === packageJson.scripts.test; const configFile = process.env.TEST_POSTGRES ? 'ci.json' : isTestMode ? 'test.json' : 'config.json'; diff --git a/tsconfig.json b/tsconfig.json index f6ee0c9..c38f013 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -74,8 +74,10 @@ /* Advanced Options */ "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ + + "resolveJsonModule": true }, "include": [ "./src/**/*"