Skip to content

Commit b3ff839

Browse files
codenemericallam
authored andcommitted
Add console logs to debug log level
1 parent bdb995e commit b3ff839

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/cli-v3/e2e/index.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ if (testCases.length > 0) {
238238
NODE_PATH: resolve(join(tempDir, "node_modules")),
239239
}
240240
);
241-
console.log(installStdout);
241+
debug(installStdout);
242242
if (installStderr) console.error(installStderr);
243243
})(),
244244
wantInstallationError ? "does not install dependencies" : "installs dependencies"
@@ -260,7 +260,7 @@ if (testCases.length > 0) {
260260
NODE_PATH: resolve(join(tempDir, "node_modules")),
261261
},
262262
});
263-
console.log(stdout);
263+
debug(stdout);
264264
if (stderr) console.error(stderr);
265265
})(),
266266
wantWorkerError ? "worker does not start" : "worker starts"
@@ -282,23 +282,29 @@ if (testCases.length > 0) {
282282
throw new Error("Nothing to test");
283283
}
284284

285+
function debug(message: string) {
286+
if (options.logLevel === "debug") {
287+
console.log(message);
288+
}
289+
}
290+
285291
async function installFixtureDeps(dir: string, packageManager: PackageManager) {
286292
if (["pnpm", "yarn"].includes(packageManager)) {
287293
const buffer = readFileSync(resolve(join(dir, "package.json")), "utf8");
288294
const pkgJSON = JSON.parse(buffer.toString());
289295
const version = pkgJSON.engines[packageManager];
290-
console.log(`Detected ${packageManager}@${version} from package.json 'engines' field`);
296+
debug(`Detected ${packageManager}@${version} from package.json 'engines' field`);
291297
const { stdout, stderr } = await execa("corepack", ["use", `${packageManager}@${version}`], {
292298
cwd: dir,
293299
});
294-
console.log(stdout);
300+
debug(stdout);
295301
if (stderr) console.error(stderr);
296302
} else {
297303
const { stdout, stderr } = await execa(packageManager, installArgs(packageManager), {
298304
cwd: dir,
299305
NODE_PATH: resolve(join(dir, "node_modules")),
300306
});
301-
console.log(stdout);
307+
debug(stdout);
302308
if (stderr) console.error(stderr);
303309
}
304310
}

packages/cli-v3/src/utilities/getUserPackageManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { logger } from "./logger";
44

55
export type PackageManager = "npm" | "pnpm" | "yarn";
66
export const LOCKFILES = {
7-
yarn: "yarn.lock",
8-
pnpm: "pnpm-lock.yaml",
97
npm: "package-lock.json",
108
npmShrinkwrap: "npm-shrinkwrap.json",
9+
pnpm: "pnpm-lock.yaml",
10+
yarn: "yarn.lock",
1111
};
1212

1313
export async function getUserPackageManager(path: string): Promise<PackageManager> {

0 commit comments

Comments
 (0)