Skip to content

Commit

Permalink
fix(#68): postinstall is failing with no error
Browse files Browse the repository at this point in the history
  • Loading branch information
feugy committed May 24, 2024
1 parent 68d3424 commit fe76ed0
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions packages/web/scripts/postinstall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,30 @@ function isAnalyticsIdInNextConfig() {
}

function main() {
if (!isSpeedInsightsInstalled()) {
// No @vercel/speed-insights installed, we don't need to continue
return;
}
try {
if (!isSpeedInsightsInstalled()) {
// No @vercel/speed-insights installed, we don't need to continue
return;
}

const isInConfig = isAnalyticsIdInNextConfig();
const envFile = findEnvFileWithAnalyticsId();
const isInConfig = isAnalyticsIdInNextConfig();
const envFile = findEnvFileWithAnalyticsId();

if (isInConfig) {
console.warn(
'\x1b[31m',
`Please remove 'analyticsId' from your next.config.js file.`,
);
}
if (envFile) {
console.log(
'\x1b[31m',
`Please remove 'VERCEL_ANALYTICS_ID' from your ${envFile} file.`,
if (isInConfig) {
console.warn(
'\x1b[31m',
`Please remove 'analyticsId' from your next.config.js file.`,
);
}
if (envFile) {
console.log(
'\x1b[31m',
`Please remove 'VERCEL_ANALYTICS_ID' from your ${envFile} file.`,
);
}
} catch (error) {
console.error(
`Failed to run @vercel/speed-insights postinstall script: ${error instanceof Error ? error.message : error}`,
);
}
}
Expand Down

0 comments on commit fe76ed0

Please sign in to comment.