Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download-plugins: display errors at the end of the script #7881

Merged
merged 1 commit into from
May 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions dev-packages/cli/src/download-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export interface DownloadPluginsOptions {
}

export default async function downloadPlugins(options: DownloadPluginsOptions = {}): Promise<void> {

// Collect the list of failures to be appended at the end of the script.
const failures: string[] = [];

const {
packed = false,
} = options;
Expand Down Expand Up @@ -109,16 +113,15 @@ export default async function downloadPlugins(options: DownloadPluginsOptions =
}
}
if (lastError) {
console.error(red(`x ${plugin}: failed to download, last error:`));
console.error(lastError);
failures.push(red(`x ${plugin}: failed to download, last error:\n ${lastError}`));
return;
}
if (typeof response === 'undefined') {
console.error(red(`x ${plugin}: failed to download (unknown reason)`));
failures.push(red(`x ${plugin}: failed to download (unknown reason)`));
return;
}
if (response.status !== 200) {
console.error(red(`x ${plugin}: failed to download with: ${response.status} ${response.statusText}`));
failures.push(red(`x ${plugin}: failed to download with: ${response.status} ${response.statusText}`));
return;
}

Expand All @@ -144,6 +147,9 @@ export default async function downloadPlugins(options: DownloadPluginsOptions =

console.warn(green(`+ ${plugin}: downloaded successfully ${attempts > 1 ? `(after ${attempts} attempts)` : ''}`));
}));
failures.forEach(failure => {
console.log(failure);
});
}

/**
Expand Down