refactor(core): Move getPackageJson utility to core package (#12224)

This commit is contained in:
Shreya Keshive
2025-10-29 13:23:35 -07:00
committed by GitHub
parent b31b786db7
commit 3e9701861e
9 changed files with 61 additions and 49 deletions
+28
View File
@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {
readPackageUp,
type PackageJson as BasePackageJson,
} from 'read-package-up';
export type PackageJson = BasePackageJson & {
config?: {
sandboxImageUri?: string;
};
};
export async function getPackageJson(
cwd: string,
): Promise<PackageJson | undefined> {
const result = await readPackageUp({ cwd });
if (!result) {
// TODO: Maybe bubble this up as an error.
return;
}
return result.packageJson;
}