File tree Expand file tree Collapse file tree
packages/apps-engine/src/definition Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 * without relying on filesystem path traversal.
55 *
66 * Uses require() instead of a static import so TypeScript does not resolve the path
7- * at compile time. The compiled output lands at definition/version.js, so
8- * '../package.json' correctly points to the package root at runtime.
7+ * at compile time.
8+ *
9+ * When running for tests, using ts-node, package.json is located two levels above the current file.
10+ * When running in production, package.json is located one level above the compiled version of this file.
911 */
10- // eslint-disable-next-line @typescript-eslint/no-require-imports
11- export const ENGINE_VERSION : string = ( require ( '../package.json' ) as { version : string } ) . version ;
12+ const runningFromSource = __dirname . endsWith ( 'src/definition' ) ;
13+ const requirePath = runningFromSource ? '../../package.json' : '../package.json' ;
14+
15+ export const ENGINE_VERSION : string = require ( requirePath ) . version ;
You can’t perform that action at this time.
0 commit comments