diff --git a/lib/ord.js b/lib/ord.js index 07b3cfb..35b0dd5 100644 --- a/lib/ord.js +++ b/lib/ord.js @@ -19,8 +19,13 @@ const cds = require("@sap/cds"); const defaults = require("./defaults"); const path = require("path"); -const initializeAppConfig = (csn) => { - let packageJsonPath = path.join(cds.root, 'package.json') +const initializeAppConfig = (csn, modelPath = cds.root || process.cwd()) => { + + if (typeof modelPath !== 'string') { + throw new TypeError(`Expected "modelPath" to be a string, but received ${typeof modelPath}: ${JSON.stringify(modelPath)}`); + } + + let packageJsonPath = path.join(modelPath, 'package.json') let packageJson; if (cds.utils.exists(packageJsonPath)) { packageJson = require(packageJsonPath);