Skip to content

Commit

Permalink
fix: generate .zenstack to the node_modules of the real path of runti…
Browse files Browse the repository at this point in the history
…me folder
  • Loading branch information
jiashengguo committed Mar 8, 2023
1 parent cef96d4 commit 52e9f82
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/schema/src/plugins/plugin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const RUNTIME_PACKAGE = '@zenstackhq/runtime';
export const ALL_OPERATION_KINDS: PolicyOperationKind[] = ['create', 'update', 'postUpdate', 'read', 'delete'];

/**
* Gets the nearest "node_modules" folder by walking up froma start path.
* Gets the nearest "node_modules" folder by walking up from start path.
*/
export function getNodeModulesFolder(startPath?: string): string | undefined {
startPath = startPath ?? process.cwd();
Expand All @@ -25,7 +25,9 @@ export function getNodeModulesFolder(startPath?: string): string | undefined {
* @returns
*/
export function getDefaultOutputFolder() {
const modulesFolder = getNodeModulesFolder();
// Find the real runtime module path, it might be a symlink in pnpm
const runtimeModulePath = require.resolve('@zenstackhq/runtime');
const modulesFolder = getNodeModulesFolder(runtimeModulePath);
return modulesFolder ? path.join(modulesFolder, '.zenstack') : undefined;
}

Expand Down

0 comments on commit 52e9f82

Please sign in to comment.