mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
fix: improve invalid package version error handling (#159)
* chore: add test case for invalid package versions * fix: add improved errors for invalid package versions
This commit is contained in:
1 parent
839215f036
commit
94c7d8acbd
3 files changed
+13
No files matched your search
@@ -67019,6 +67019,10 @@ async function resolvePackage(name, range) {
|
||||
catch (error) {
|
||||
throw new Error(`Could not resolve ${name}@${range}, reason:\n${error.message || error}`);
|
||||
}
|
||||
// thanks npm, for returning a "" json string value for invalid versions
|
||||
if (!stdout) {
|
||||
throw new Error(`Could not resolve ${name}@${range}, reason:\nInvalid version`);
|
||||
}
|
||||
// thanks npm, for returning a "x.x.x" json value...
|
||||
if (stdout.startsWith('"')) {
|
||||
stdout = `[${stdout}]`;
|
||||
|
||||
@@ -17,6 +17,11 @@ export async function resolvePackage(name: string, range: string): Promise<strin
|
||||
throw new Error(`Could not resolve ${name}@${range}, reason:\n${error.message || error}`);
|
||||
}
|
||||
|
||||
// thanks npm, for returning a "" json string value for invalid versions
|
||||
if (!stdout) {
|
||||
throw new Error(`Could not resolve ${name}@${range}, reason:\nInvalid version`);
|
||||
}
|
||||
|
||||
// thanks npm, for returning a "x.x.x" json value...
|
||||
if (stdout.startsWith('"')) {
|
||||
stdout = `[${stdout}]`;
|
||||
|
||||
@@ -22,4 +22,8 @@ describe(resolvePackage, () => {
|
||||
'Could not resolve'
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects expo-cli@9999999 with proper error', async () => {
|
||||
await expect(resolvePackage('expo-cli', '9999999')).rejects.toThrow('Could not resolve');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user