Skip to content

Commit

Permalink
feat: detect package manager for fix cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoid committed Sep 13, 2023
1 parent dc2ad79 commit d1ff396
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@manypkg/get-packages": "^2.2.0",
"chalk": "^2.4.2",
"detect-indent": "^6.0.0",
"detect-package-manager": "^3.0.1",
"find-up": "^4.1.0",
"fs-extra": "^8.1.0",
"normalize-path": "^3.0.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";
import * as logger from "./logger";
import { getPackages, Packages, Package } from "@manypkg/get-packages";
import { PM, detect as detectPackageManager } from "detect-package-manager";
import { Options } from "./checks/utils";
import { checks } from "./checks";
import { ExitError } from "./errors";
Expand Down Expand Up @@ -146,6 +147,9 @@ async function execCmd(args: string[]) {
shouldFix,
options
);
const packageManager: PM = await detectPackageManager({
cwd: rootDir,
}).catch(() => "yarn");
if (shouldFix) {
await Promise.all(
[...packagesByName].map(async ([pkgName, workspace]) => {
Expand All @@ -158,7 +162,9 @@ async function execCmd(args: string[]) {

logger.success(`fixed workspaces!`);
} else if (hasErrored) {
logger.info(`the above errors may be fixable with yarn manypkg fix`);
logger.info(
`the above errors may be fixable with ${packageManager} manypkg fix`
);
throw new ExitError(1);
} else {
logger.success(`workspaces valid!`);
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4942,6 +4942,13 @@ detect-node@^2.0.4:
resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c"
integrity sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==

detect-package-manager@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/detect-package-manager/-/detect-package-manager-3.0.1.tgz#ec9689915b47e2ecf3774118849bc7033f0a2151"
integrity sha512-qoHDH6+lMcpJPAScE7+5CYj91W0mxZNXTwZPrCqi1KMk+x+AoQScQ2V1QyqTln1rHU5Haq5fikvOGHv+leKD8A==
dependencies:
execa "^5.1.1"

[email protected]:
version "1.1.3"
resolved "https://registry.yarnpkg.com/detect-port-alt/-/detect-port-alt-1.1.3.tgz#a4d2f061d757a034ecf37c514260a98750f2b131"
Expand Down Expand Up @@ -5784,7 +5791,7 @@ execa@^2.0.4:
signal-exit "^3.0.2"
strip-final-newline "^2.0.0"

execa@^5.0.0:
execa@^5.0.0, execa@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==
Expand Down

0 comments on commit d1ff396

Please sign in to comment.