Skip to content

Commit e5ff953

Browse files
committed
use debug, not console.log
1 parent 1782287 commit e5ff953

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

packages/compass-smoke-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@mongodb-js/eslint-config-compass": "^1.2.2",
3535
"@mongodb-js/prettier-config-compass": "^1.1.2",
3636
"@mongodb-js/tsconfig-compass": "^1.1.2",
37+
"debug": "^4.3.4",
3738
"depcheck": "^1.4.1",
3839
"eslint": "^7.25.0",
3940
"hadron-build": "^25.6.2",

packages/compass-smoke-tests/src/build-info.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import assert from 'node:assert/strict';
22
import fs from 'node:fs';
33
import path from 'node:path';
44

5+
import createDebug from 'debug';
56
import { handler as writeBuildInfo } from 'hadron-build/commands/info';
67

78
import { type PackageKind } from './packages';
89
import { type SmokeTestsContext } from './context';
910
import { pick } from 'lodash';
1011

12+
const debug = createDebug('compass-smoke-tests:build-info');
13+
1114
const SUPPORTED_CHANNELS = ['dev', 'beta', 'stable'] as const;
1215
type Channel = typeof SUPPORTED_CHANNELS[number];
1316

@@ -242,11 +245,11 @@ export function writeAndReadPackageDetails(
242245
arch: context.arch,
243246
out: path.resolve(context.sandboxPath, 'target.json'),
244247
};
245-
console.log({ infoArgs });
248+
debug({ infoArgs });
246249

247250
// These are known environment variables that will affect the way
248251
// writeBuildInfo works. Log them as a reminder and for our own sanity
249-
console.log(
252+
debug(
250253
'info env vars',
251254
pick(process.env, [
252255
'HADRON_DISTRIBUTION',

packages/compass-smoke-tests/src/cli.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from 'node:path';
66
import yargs from 'yargs';
77
import { hideBin } from 'yargs/helpers';
88
import { pick } from 'lodash';
9+
import createDebug from 'debug';
910
import { execute } from './execute';
1011
import {
1112
type PackageDetails,
@@ -22,6 +23,8 @@ import { installMacDMG } from './installers/mac-dmg';
2223
import { installMacZIP } from './installers/mac-zip';
2324
import { installWindowsZIP } from './installers/windows-zip';
2425

26+
const debug = createDebug('compass-smoke-tests');
27+
2528
const SUPPORTED_PLATFORMS = ['win32', 'darwin', 'linux'] as const;
2629
const SUPPORTED_ARCHS = ['x64', 'arm64'] as const;
2730

@@ -166,9 +169,9 @@ async function run() {
166169
sandboxPath: createSandbox(),
167170
};
168171

169-
console.log(`Running tests in ${context.sandboxPath}`);
172+
debug(`Running tests in ${context.sandboxPath}`);
170173

171-
console.log(
174+
debug(
172175
'context',
173176
pick(context, [
174177
'forceDownload',
@@ -196,11 +199,11 @@ async function run() {
196199
await uninstall();
197200
}
198201
} finally {
199-
console.log('Cleaning up sandbox');
202+
debug('Cleaning up sandbox');
200203
fs.rmSync(context.sandboxPath, { recursive: true });
201204
}
202205

203-
console.log('update from latest release to this package');
206+
debug('update from latest release to this package');
204207
const releasepath = await getLatestRelease(
205208
buildInfo.channel,
206209
context.arch,
@@ -223,7 +226,7 @@ async function run() {
223226
await uninstall();
224227
}
225228
} finally {
226-
console.log('Cleaning up sandbox');
229+
debug('Cleaning up sandbox');
227230
fs.rmSync(context.sandboxPath, { recursive: true });
228231
}
229232
}
@@ -259,7 +262,7 @@ function runTest({ appName, appPath }: RunTestOptions) {
259262

260263
run()
261264
.then(function () {
262-
console.log('done');
265+
debug('done');
263266
})
264267
.catch(function (err) {
265268
console.error(err.stack);

packages/compass-smoke-tests/src/downloads.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ import fs from 'node:fs';
33
import path from 'node:path';
44
import stream from 'node:stream';
55

6+
import createDebug from 'debug';
7+
68
import { ensureDownloadsDirectory } from './directories';
79

10+
const debug = createDebug('compass-smoke-tests:downloads');
11+
812
type DownloadFileOptions = {
913
url: string;
1014
targetFilename: string;
@@ -33,7 +37,7 @@ export async function downloadFile({
3337
if (clearCache) {
3438
fs.rmSync(cacheDirectoryPath, { recursive: true, force: true });
3539
} else {
36-
console.log('Skipped downloading', url, '(cache existed)');
40+
debug(`Skipped downloading ${url} (cache existed)`);
3741
return outputPath;
3842
}
3943
}
@@ -44,13 +48,11 @@ export async function downloadFile({
4448

4549
// Write the response to file
4650
assert(response.body, 'Expected a response body');
47-
console.log('Downloading', url);
51+
debug(`Downloading ${url} to ${outputPath}`);
4852
await stream.promises.pipeline(
4953
response.body,
5054
fs.createWriteStream(outputPath)
5155
);
5256

53-
console.log(outputPath);
54-
5557
return outputPath;
5658
}

packages/compass-smoke-tests/src/installers/mac-dmg.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import path from 'node:path';
22
import fs from 'node:fs';
33

4+
import createDebug from 'debug';
5+
46
import type { InstalledAppInfo, InstallablePackage } from './types';
57
import { execute } from '../execute';
68

9+
const debug = createDebug('compass-smoke-tests:installers:mac-dmg');
10+
711
export function installMacDMG({
812
appName,
913
filepath,
@@ -35,7 +39,7 @@ export function installMacDMG({
3539
);
3640

3741
if (fs.existsSync(settingsDir)) {
38-
console.log(`${settingsDir} already exists. Removing.`);
42+
debug(`${settingsDir} already exists. Removing.`);
3943
fs.rmSync(settingsDir, { recursive: true });
4044
}
4145
}

packages/compass-smoke-tests/src/installers/mac-zip.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import path from 'node:path';
22
import fs from 'node:fs';
33

4+
import createDebug from 'debug';
5+
46
import type { InstalledAppInfo, InstallablePackage } from './types';
57
import { execute } from '../execute';
68

9+
const debug = createDebug('compass-smoke-tests:installers:mac-zip');
10+
711
export function installMacZIP({
812
appName,
913
filepath,
@@ -25,7 +29,7 @@ export function installMacZIP({
2529
);
2630

2731
if (fs.existsSync(settingsDir)) {
28-
console.log(`${settingsDir} already exists. Removing.`);
32+
debug(`${settingsDir} already exists. Removing.`);
2933
fs.rmSync(settingsDir, { recursive: true });
3034
}
3135
}

0 commit comments

Comments
 (0)