Skip to content

Commit

Permalink
print warning in case developers are using a different package manage…
Browse files Browse the repository at this point in the history
…r to run @cloudflare/next-on-pages (#554)
  • Loading branch information
dario-piotrowicz authored Nov 28, 2023
1 parent b7f9225 commit 61d0a2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/blue-seals-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudflare/next-on-pages': patch
---

print warning in case developers are using a different package manager to run @cloudflare/next-on-pages
11 changes: 10 additions & 1 deletion packages/next-on-pages/src/buildApplication/buildApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join, resolve } from 'path';
import { cp } from 'fs/promises';
import { getPackageManager } from 'package-manager-manager';
import type { CliOptions } from '../cli';
import { cliError, cliLog, cliSuccess } from '../cli';
import { cliError, cliLog, cliSuccess, cliWarn } from '../cli';
import { getVercelConfig } from './getVercelConfig';
import { buildWorkerFile } from './buildWorkerFile';
import { buildVercelOutput } from './buildVercelOutput';
Expand Down Expand Up @@ -43,6 +43,15 @@ export async function buildApplication({
throw new Error('Error: Could not detect current package manager in use');
}

if (pm.projectPackageManager && pm.name !== pm.projectPackageManager) {
cliWarn(
`The project is set up for ${pm.projectPackageManager} but it is currently being run` +
` via ${pm.name} this might lead to build errors, please be sure to use the same package manager` +
` your project uses when running @cloudflare/next-on-pages`,
{ spaced: true },
);
}

let buildSuccess = true;
if (!skipBuild) {
try {
Expand Down

0 comments on commit 61d0a2f

Please sign in to comment.