File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed
Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ export default tseslint.config(
2929 // Global ignores
3030 ignores : [
3131 'node_modules/*' ,
32- '.integration-tests/**' ,
3332 'eslint.config.js' ,
3433 'packages/**/dist/**' ,
3534 'bundle/**' ,
Original file line number Diff line number Diff line change 66 * SPDX-License-Identifier: Apache-2.0
77 */
88
9- import './src/gemini.js' ;
109import { main } from './src/gemini.js' ;
1110import { FatalError , writeToStderr } from '@google/gemini-cli-core' ;
1211import { runExitCleanup } from './src/utils/cleanup.js' ;
Original file line number Diff line number Diff line change @@ -15,13 +15,26 @@ export type PackageJson = BasePackageJson & {
1515 } ;
1616} ;
1717
18+ /**
19+ * Reads package.json from the current directory or any parent directory.
20+ *
21+ * @param cwd - The directory to start searching from (searches upward to filesystem root)
22+ * @returns The package.json object if found, or `undefined` if no package.json exists
23+ * in the directory hierarchy. This is expected behavior when called from
24+ * directories outside of a Node.js project.
25+ *
26+ * @example
27+ * ```ts
28+ * const pkg = await getPackageJson(__dirname);
29+ * const version = pkg?.version ?? 'unknown';
30+ * ```
31+ */
1832export async function getPackageJson (
1933 cwd : string ,
2034) : Promise < PackageJson | undefined > {
2135 const result = await readPackageUp ( { cwd } ) ;
2236 if ( ! result ) {
23- // TODO: Maybe bubble this up as an error.
24- return ;
37+ return undefined ;
2538 }
2639
2740 return result . packageJson ;
You can’t perform that action at this time.
0 commit comments