MCPcopy Create free account
hub / github.com/remix-run/react-router / getPackages

Function getPackages

scripts/changes/add.ts:167–187  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

165// --- Utils ---
166
167function getPackages(): Package[] {
168 return getAllPackageDirNames()
169 .map((dirName) => {
170 let pkgJsonPath = path.join(getPackagePath(dirName), "package.json");
171 if (!fs.existsSync(pkgJsonPath)) return null;
172 let { name } = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
173 return { dirName, name } as Package;
174 })
175 .filter((p): p is Package => p !== null)
176 .sort((a, b) => {
177 const order = (name: string) => {
178 if (name === "react-router") return 0;
179 if (name.startsWith("@react-router/")) return 1;
180 return 2;
181 };
182 const oa = order(a.name);
183 const ob = order(b.name);
184 if (oa !== ob) return oa - ob;
185 return a.name.localeCompare(b.name);
186 });
187}
188
189/**
190 * Converts a free-text description into a kebab-case slug of at most 6

Callers 1

add.tsFile · 0.85

Calls 4

getAllPackageDirNamesFunction · 0.90
getPackagePathFunction · 0.90
parseMethod · 0.80
orderFunction · 0.70

Tested by

no test coverage detected