diff --git a/scripts/pre-gen/setHostsOptions.ts b/scripts/pre-gen/setHostsOptions.ts index feef141da3..872a5837bf 100644 --- a/scripts/pre-gen/setHostsOptions.ts +++ b/scripts/pre-gen/setHostsOptions.ts @@ -32,7 +32,12 @@ type AdditionalProperties = Partial<{ }>; async function setHostsOptions(): Promise { - const openapitoolsPath = path.join(__dirname, '../../openapitools.json'); + const openapitoolsPath = path.join(process.cwd(), '../openapitools.json'); + if (!(await stat(openapitoolsPath))) { + throw new Error( + `File not found ${openapitoolsPath}.\nMake sure your run scripts from the root directory using yarn workspace.` + ); + } const openapitools = JSON.parse(await readFile(openapitoolsPath, 'utf-8')); const [language, client] = process.argv.slice(2); @@ -43,10 +48,12 @@ async function setHostsOptions(): Promise { throw new Error(`Generator not found: ${generator}`); } - const specPath = path.join(__dirname, `../../specs/bundled/${client}.yml`); + const specPath = path.join(process.cwd(), `../specs/bundled/${client}.yml`); if (!(await stat(specPath))) { - throw new Error(`File not found ${specPath}`); + throw new Error( + `File not found ${specPath}.\nMake sure your run scripts from the root directory using yarn workspace.` + ); } try {