Skip to content

Commit

Permalink
feat(debug): attach pkg prefixes to debug notes
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Dec 30, 2020
1 parent bfb570e commit 25e111f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
15 changes: 8 additions & 7 deletions lib/createInlinePluginCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
function createInlinePlugin(pkg) {
// Vars.
const { plugins, dir, name } = pkg;
const debugPrefix = `[${name}]`;
const next = () => {
pkg._tagged = true;

Expand Down Expand Up @@ -66,7 +67,7 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)

const res = await plugins.verifyConditions(context);

debug("verified conditions: %s", pkg.name);
debug(debugPrefix, "verified conditions");

return res;
};
Expand Down Expand Up @@ -107,8 +108,8 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
// Make sure type is "patch" if the package has any deps that have changed.
pkg._nextType = resolveReleaseType(pkg, flags.deps.bump, flags.deps.release);

debug("commits analyzed: %s", pkg.name);
debug("release type: %s", pkg._nextType);
debug(debugPrefix, "commits analyzed");
debug(debugPrefix, `release type: ${pkg._nextType}`);

// Return type.
return pkg._nextType;
Expand Down Expand Up @@ -168,7 +169,7 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
notes.push(bullets.join("\n"));
}

debug("notes generated: %s", pkg.name);
debug(debugPrefix, "notes generated");

if (pkg.options.dryRun) {
next();
Expand All @@ -189,7 +190,7 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
const res = await plugins.prepare(context);
pkg._prepared = true;

debug("prepared: %s", pkg.name);
debug(debugPrefix, "prepared");

return res;
};
Expand All @@ -201,7 +202,7 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
const res = await resPromise;
pkg._published = true;

debug("published: %s", pkg.name);
debug(debugPrefix, "published");

// istanbul ignore next
return res.length ? res[0] : {};
Expand All @@ -224,7 +225,7 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
})
);

debug("inlinePlugin created: %s", pkg.name);
debug(debugPrefix, "inlinePlugin created");

return inlinePlugin;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/getSynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getSynchronizer = (packages) => {

const emit = (probe, pkg) => {
const name = getEventName(probe, pkg);
debug("ready: %s", name);
debug(`[${pkg ? pkg.name : "ALL"}]`, name);

return store.evt[name] || (store.evt[name] = ee.emit(name));
};
Expand All @@ -57,7 +57,6 @@ const getSynchronizer = (packages) => {
.filter(filter)
.every((p) => p.hasOwnProperty(probe))
) {
debug("ready: %s", probe);
emit(probe);
}

Expand All @@ -70,7 +69,7 @@ const getSynchronizer = (packages) => {
return;
}
const name = getEventName(probe, pkg);
debug("lucky: %s", name);
debug(`[${pkg.name}]`, "is lucky", name);

getLucky[probe] = emit(probe, pkg);
};
Expand Down
7 changes: 4 additions & 3 deletions lib/updateDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const difference = (object, base) =>
* @internal
*/
const auditManifestChanges = (actualManifest, path) => {
const debugPrefix = `[${actualManifest.name}]`;
const oldManifest = getManifest(path);
const depScopes = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
const changes = depScopes.reduce((res, scope) => {
Expand All @@ -216,14 +217,14 @@ const auditManifestChanges = (actualManifest, path) => {
return res;
}, {});

debug(actualManifest.name, path);
debug(debugPrefix, "package.json path=", path);

if (Object.keys(changes).length) {
debug(changes);
debug(debugPrefix, "changes=", changes);
return true;
}

debug("no deps changes");
debug(debugPrefix, "no deps changes");
return false;
};

Expand Down

0 comments on commit 25e111f

Please sign in to comment.