Skip to content

Commit

Permalink
feat: improve installation jobs reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Nov 15, 2018
1 parent dcd0258 commit 618b22f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
9 changes: 7 additions & 2 deletions lib/private/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,23 @@ module.exports = async (command, packageName, inputOptions) => {
log.notice("installed %s", endedPackageName);
} else if (installationJobs.size) {
const jobTerms = new Set();
let updatedDependenciesCount = 0;
let updatedDependenciesCount = 0, installedDependenciesCount = 0;
for (const job of installationJobs) {
if (job === "pull") jobTerms.add("pulled");
else if (job === "push") jobTerms.add("pushed");
else if (job === "link") jobTerms.add("linked");
else if (job.startsWith("setup-dependency:")) ++updatedDependenciesCount;
else if (job.startsWith("update-dependency:")) ++updatedDependenciesCount;
else if (job.startsWith("install-dependency:")) ++installedDependenciesCount;
}
if (updatedDependenciesCount === 1) {
jobTerms.add("updated 1 dependency");
} else if (updatedDependenciesCount > 1) {
jobTerms.add(`updated ${ updatedDependenciesCount } dependencies`);
}
if (!installationJobs.has("link") && installedDependenciesCount) {
if (installedDependenciesCount === 1) jobTerms.add("installed 1 dependency");
else jobTerms.add(`installed ${ installedDependenciesCount } dependencies`);
}
log.notice("updated %s (%#s)", endedPackageName, Array.from(jobTerms).join(", "));
}
updateProgress();
Expand Down
9 changes: 7 additions & 2 deletions lib/private/setup-dependencies/setup-dependency/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ module.exports = async (dependencyContext, userConfiguration, inputOptions, prog
{ name }, userConfiguration, inputOptions, progressData
);
}
if ((done.get(name) || ongoing.get(name)).installationJobs.size) {
dependentContext.installationJobs.add(`setup-dependency:${ name }`);
const dependencyInstallationJobs = (done.get(name) || ongoing.get(name)).installationJobs;
if (dependencyInstallationJobs.size) {
dependentContext.installationJobs.add(
`$${ dependencyInstallationJobs.has("clone") ? "install" : "update" }-dependency:${
name
}`
);
}
}
await npmLinkDependency(dependencyContext, progressData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = async (dependencyContext, progressData) => {
return;
}

dependentContext.installationJobs.add(`setup-dependency:${ name }`);
dependentContext.installationJobs.add(`install-dependency:${ name }`);
if (ongoing.has(name)) {
ongoing
.get(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = async dependencyContext => {
);
if (!sourceDirname) return;

dependentContext.installationJobs.add(`setup-dependency:${ name }`);
dependentContext.installationJobs.add(`install-dependency:${ name }`);
await copyDir(sourceDirname, path);

// Ensure to map binaries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = async (dependencyContext, progressData) => {
return;
}

dependentContext.installationJobs.add(`setup-dependency:${ name }`);
dependentContext.installationJobs.add(`install-dependency:${ name }`);
log.info("%s link external dependency %s", dependentContext.name, name);
await rm(path, { loose: true, recursive: true, force: true });
await muteErrorIfOptional(dependencyContext, async () => {
Expand Down

0 comments on commit 618b22f

Please sign in to comment.