Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue that caused multiple packages to be seleceted #108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added packages/.DS_Store
Binary file not shown.
9 changes: 5 additions & 4 deletions packages/cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getPackages } from "@manypkg/get-packages";
import path from "path";
import spawn from "spawndamnit";
import * as logger from "./logger";
import { GetPrefix } from "./utils";
import { ExitError } from "./errors";

export async function runCmd(args: string[], cwd: string) {
Expand All @@ -23,10 +24,10 @@ export async function runCmd(args: string[], cwd: string) {
}

const matchingPackages = packages.filter(pkg => {
return (
pkg.packageJson.name.includes(args[0]) ||
path.relative(root.dir, pkg.dir).includes(args[0])
);
const prefixed = `${GetPrefix(pkg.packageJson)}/${args[0]}`

if (prefixed === pkg.packageJson.name)
return prefixed
});

if (matchingPackages.length > 1) {
Expand Down
11 changes: 11 additions & 0 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ export async function install(tool: Tool, cwd: string) {
{ cwd, stdio: "inherit" }
);
}

export function GetPrefix(packagejson: Package["packageJson"]){
const name = packagejson.name
const splitName = name.split("/")


if(splitName.length === 0)
throw new Error("Invalid package name. Please use '/' to separate the package with it's scope")

return splitName[0]
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14074,10 +14074,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
typescript@^4.0.3:
version "4.3.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==

ua-parser-js@^0.7.18:
version "0.7.20"
Expand Down