Skip to content

Commit

Permalink
chore: use package path for dist folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mutahhir committed Jul 14, 2023
1 parent 245b4bf commit 54833e3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/cdktf-cli/src/bin/cmds/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,21 @@ async function getProviderRequirements(provider: string[]) {
return [...provider, ...providersFromConfig];
}

const readPackageJson = () => {
let packagePath: string | undefined;
const getPackageJsonPath = () => {
if (packagePath) {
return packagePath;
}
const pkgPath = pkgUp.sync({ cwd: __dirname });
if (!pkgPath) {
throw new Error("unable to find package.json");
}
packagePath = pkgPath;
return packagePath;
};

const readPackageJson = () => {
const pkgPath = getPackageJsonPath();
return JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
};

Expand Down Expand Up @@ -121,7 +130,8 @@ export async function convert({ language, provider, stack }: any) {
const origDir = process.cwd();
process.chdir(tempDir);

const dist = path.resolve(__dirname, "../../../../../dist");
const packagePath = getPackageJsonPath();
const dist = path.resolve(packagePath, "./dist");

logger.setLevel("ERROR");
await init({
Expand Down

0 comments on commit 54833e3

Please sign in to comment.