@tutinoko2048/mcutil 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +9 -8
- package/package.json +1 -1
- package/src/commands/pkg.ts +13 -10
package/dist/cli.mjs
CHANGED
|
@@ -166,28 +166,29 @@ async function detectPackageManagers(cwd) {
|
|
|
166
166
|
const checks = [
|
|
167
167
|
{
|
|
168
168
|
name: "pnpm",
|
|
169
|
-
|
|
169
|
+
files: ["pnpm-lock.yaml"]
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
name: "npm",
|
|
173
|
-
|
|
173
|
+
files: ["package-lock.json"]
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
name: "yarn",
|
|
177
|
-
|
|
177
|
+
files: ["yarn.lock"]
|
|
178
178
|
},
|
|
179
179
|
{
|
|
180
180
|
name: "bun",
|
|
181
|
-
|
|
181
|
+
files: ["bun.lock", "bun.lockb"]
|
|
182
182
|
}
|
|
183
183
|
];
|
|
184
184
|
const matches = [];
|
|
185
185
|
await Promise.all(checks.map(async (check) => {
|
|
186
|
-
try {
|
|
187
|
-
await fs.access(path.join(cwd,
|
|
186
|
+
for (const file of check.files) try {
|
|
187
|
+
await fs.access(path.join(cwd, file));
|
|
188
188
|
matches.push(check.name);
|
|
189
|
+
break;
|
|
189
190
|
} catch {
|
|
190
|
-
|
|
191
|
+
continue;
|
|
191
192
|
}
|
|
192
193
|
}));
|
|
193
194
|
return matches;
|
|
@@ -356,7 +357,7 @@ function registerPkgCommand(program) {
|
|
|
356
357
|
|
|
357
358
|
//#endregion
|
|
358
359
|
//#region package.json
|
|
359
|
-
var version = "1.0.
|
|
360
|
+
var version = "1.0.4";
|
|
360
361
|
|
|
361
362
|
//#endregion
|
|
362
363
|
//#region src/cli.ts
|
package/package.json
CHANGED
package/src/commands/pkg.ts
CHANGED
|
@@ -94,21 +94,24 @@ function getCurrentVersion(pkgJson: PackageJson, name: string): string | null {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
async function detectPackageManagers(cwd: string): Promise<PackageManager[]> {
|
|
97
|
-
const checks: Array<{ name: PackageManager;
|
|
98
|
-
{ name: "pnpm",
|
|
99
|
-
{ name: "npm",
|
|
100
|
-
{ name: "yarn",
|
|
101
|
-
{ name: "bun",
|
|
97
|
+
const checks: Array<{ name: PackageManager; files: string[] }> = [
|
|
98
|
+
{ name: "pnpm", files: ["pnpm-lock.yaml"] },
|
|
99
|
+
{ name: "npm", files: ["package-lock.json"] },
|
|
100
|
+
{ name: "yarn", files: ["yarn.lock"] },
|
|
101
|
+
{ name: "bun", files: ["bun.lock", "bun.lockb"] },
|
|
102
102
|
];
|
|
103
103
|
|
|
104
104
|
const matches: PackageManager[] = [];
|
|
105
105
|
await Promise.all(
|
|
106
106
|
checks.map(async (check) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
for (const file of check.files) {
|
|
108
|
+
try {
|
|
109
|
+
await fs.access(path.join(cwd, file));
|
|
110
|
+
matches.push(check.name);
|
|
111
|
+
break;
|
|
112
|
+
} catch {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
112
115
|
}
|
|
113
116
|
})
|
|
114
117
|
);
|