Skip to content

Commit fcb95f3

Browse files
authored
feat: warn about missing manifest (#235)
1 parent 03cbef7 commit fcb95f3

File tree

2 files changed

+220
-11
lines changed

2 files changed

+220
-11
lines changed

dist/index.mjs

Lines changed: 200 additions & 11 deletions
Large diffs are not rendered by default.

src/version.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const getBiomeVersion = async (octokit: Octokit): Promise<string> => {
4848

4949
return (
5050
getInput("version") ??
51+
warnAboutMissingPackageJsonManifest(root) ??
5152
(await extractVersionFromNpmLockFile(root)) ??
5253
(await extractVersionFromPnpmLockFile(root)) ??
5354
(await extractVersionFromYarnLockFile(root)) ??
@@ -57,6 +58,25 @@ export const getBiomeVersion = async (octokit: Octokit): Promise<string> => {
5758
);
5859
};
5960

61+
/**
62+
* Warns the user if the package.json file is missing in the project root.
63+
*
64+
* If the package.json file is missing from the working directory, it is likely
65+
* that the user has not checked out the repository. This function will
66+
* display a warning message to the user, indicating that the package.json
67+
* file is missing and suggesting that the user check out the repository.
68+
*
69+
* @returns {undefined} Always returns undefined.
70+
*/
71+
const warnAboutMissingPackageJsonManifest = (root: string) => {
72+
if (!existsSync(join(root, "package.json"))) {
73+
warning(
74+
"Cannot find package.json in the working directory. Did you forget to checkout the repository?",
75+
);
76+
}
77+
return undefined;
78+
};
79+
6080
/**
6181
* Extracts the Biome CLI version from the project's
6282
* package-lock.json file.

0 commit comments

Comments
 (0)