Skip to content

Commit

Permalink
fix: handle pkg with version in noInstall mode (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyisdev authored Jul 19, 2022
1 parent cf7be5a commit 5737beb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/runPkgManagerInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export const runPkgManagerInstall = async (
continue;
}

const pkgName = pkg.replace(/^(@?[^@]+)(?:@.+)?$/, "$1");

// Note: We know that pkgJson.[dev]Dependencies exists in the base Next.js template so we don't need to validate it
if (devMode) {
pkgJson.devDependencies![pkg] = `^${latestVersion.trim()}`; //eslint-disable-line @typescript-eslint/no-non-null-assertion
pkgJson.devDependencies![pkgName] = `^${latestVersion.trim()}`; //eslint-disable-line @typescript-eslint/no-non-null-assertion
} else {
pkgJson.dependencies![pkg] = `^${latestVersion.trim()}`; //eslint-disable-line @typescript-eslint/no-non-null-assertion
pkgJson.dependencies![pkgName] = `^${latestVersion.trim()}`; //eslint-disable-line @typescript-eslint/no-non-null-assertion
}
}

Expand Down

0 comments on commit 5737beb

Please sign in to comment.