From 741a7ed0db4bb2e10ce586a00621803678d344b1 Mon Sep 17 00:00:00 2001 From: KieSun Date: Mon, 3 Jan 2022 20:20:16 +0800 Subject: [PATCH 1/3] fix: pnpx command is deprecated in version 6.x --- create-turbo/src/index.ts | 4 ++-- create-turbo/src/shouldUsePnpm.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/create-turbo/src/index.ts b/create-turbo/src/index.ts index 8c770ed55756d..1be2735a74e47 100644 --- a/create-turbo/src/index.ts +++ b/create-turbo/src/index.ts @@ -11,7 +11,7 @@ import checkForUpdate from "update-check"; import chalk from "chalk"; import cliPkgJson from "../package.json"; import { shouldUseYarn } from "./shouldUseYarn"; -import { shouldUsePnpm } from "./shouldUsePnpm"; +import { shouldUsePnpm, getNpxCommandOfPnpm } from "./shouldUsePnpm"; import { tryGitInit } from "./git"; type PackageManager = "yarn" | "pnpm" | "npm"; @@ -310,7 +310,7 @@ function getNpxCommand(pkgManager: PackageManager): string { if (pkgManager === "yarn") { return "npx"; } else if (pkgManager === "pnpm") { - return "pnpx"; + return getNpxCommandOfPnpm(); } else { return "npx"; } diff --git a/create-turbo/src/shouldUsePnpm.ts b/create-turbo/src/shouldUsePnpm.ts index 9350f82ba9f78..3f69925126873 100644 --- a/create-turbo/src/shouldUsePnpm.ts +++ b/create-turbo/src/shouldUsePnpm.ts @@ -1,3 +1,4 @@ +import semver from "semver"; import { execSync } from "child_process"; export function shouldUsePnpm(): boolean { @@ -12,3 +13,8 @@ export function shouldUsePnpm(): boolean { return false; } } + +export function getNpxCommandOfPnpm() { + const currentVersion = execSync("pnpm --version").toString(); + return semver.gte(currentVersion, "6.0.0") ? "pnpm dlx" : "pnpx"; +} From 620db1155102aa0d18450e5d4c42e5162668c332 Mon Sep 17 00:00:00 2001 From: xuwu Date: Tue, 4 Jan 2022 08:19:36 +0800 Subject: [PATCH 2/3] feat: use charAt replace semver --- create-turbo/src/shouldUsePnpm.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/create-turbo/src/shouldUsePnpm.ts b/create-turbo/src/shouldUsePnpm.ts index 3f69925126873..3a6dcbbb8aafa 100644 --- a/create-turbo/src/shouldUsePnpm.ts +++ b/create-turbo/src/shouldUsePnpm.ts @@ -1,4 +1,3 @@ -import semver from "semver"; import { execSync } from "child_process"; export function shouldUsePnpm(): boolean { @@ -16,5 +15,5 @@ export function shouldUsePnpm(): boolean { export function getNpxCommandOfPnpm() { const currentVersion = execSync("pnpm --version").toString(); - return semver.gte(currentVersion, "6.0.0") ? "pnpm dlx" : "pnpx"; + return Number(currentVersion.charAt(0)) >= 6 ? "pnpm dlx" : "pnpx"; } From fd90abd099e4c68d36e1279ef068cf86876ce2b7 Mon Sep 17 00:00:00 2001 From: KieSun Date: Tue, 4 Jan 2022 10:57:57 +0800 Subject: [PATCH 3/3] fix: version maybe >= 10 --- create-turbo/src/shouldUsePnpm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-turbo/src/shouldUsePnpm.ts b/create-turbo/src/shouldUsePnpm.ts index 3a6dcbbb8aafa..ad2ed8b26c7e0 100644 --- a/create-turbo/src/shouldUsePnpm.ts +++ b/create-turbo/src/shouldUsePnpm.ts @@ -15,5 +15,5 @@ export function shouldUsePnpm(): boolean { export function getNpxCommandOfPnpm() { const currentVersion = execSync("pnpm --version").toString(); - return Number(currentVersion.charAt(0)) >= 6 ? "pnpm dlx" : "pnpx"; + return Number(currentVersion.split(".")[0]) >= 6 ? "pnpm dlx" : "pnpx"; }