Skip to content

Commit

Permalink
Highlight private packages in updated/publish output (#436)
Browse files Browse the repository at this point in the history
* add styling to private annotation in UpdatedCommand.js

* add styled private annotation to changes in PublishCommand
  • Loading branch information
chrishelgert authored and gigabo committed Dec 14, 2016
1 parent d707386 commit f325820
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/commands/PublishCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import NpmUtilities from "../NpmUtilities";
import Command from "../Command";
import semver from "semver";
import async from "async";
import chalk from "chalk";
import path from "path";
import { EOL } from "os";

Expand Down Expand Up @@ -232,7 +233,8 @@ export default class PublishCommand extends Command {
this.logger.newLine();
this.logger.info("Changes:");
this.logger.info(this.updates.map((update) => {
return `- ${update.package.name}: ${update.package.version} => ${this.updatesVersions[update.package.name]}`;
const pkg = update.package;
return `- ${pkg.name}: ${pkg.version} => ${this.updatesVersions[pkg.name]}${pkg.isPrivate() ? ` (${chalk.red("private")})` : ""}`;
}).join(EOL));
this.logger.newLine();

Expand Down
3 changes: 2 additions & 1 deletion src/commands/UpdatedCommand.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UpdatedPackagesCollector from "../UpdatedPackagesCollector";
import Command from "../Command";
import chalk from "chalk";

export default class UpdatedCommand extends Command {
initialize(callback) {
Expand All @@ -16,7 +17,7 @@ export default class UpdatedCommand extends Command {

execute(callback) {
const formattedUpdates = this.updates
.map((update) => `- ${update.package.name}${update.package.isPrivate() ? " (private)" : ""}`)
.map((update) => `- ${update.package.name}${update.package.isPrivate() ? ` (${chalk.red("private")})` : ""}`)
.join("\n");

this.logger.newLine();
Expand Down
5 changes: 3 additions & 2 deletions test/UpdatedCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import child from "child_process";
import path from "path";
import fs from "fs";
import syncExec from "sync-exec";
import chalk from "chalk";

import UpdatedCommand from "../src/commands/UpdatedCommand";
import exitWithCode from "./_exitWithCode";
Expand Down Expand Up @@ -63,7 +64,7 @@ describe("UpdatedCommand", () => {
let calls = 0;
stub(logger, "info", (message) => {
if (calls === 0) assert.equal(message, "Checking for updated packages...");
if (calls === 2) assert.equal(message, "- package-1\n- package-2\n- package-3\n- package-4");
if (calls === 2) assert.equal(message, `- package-1\n- package-2\n- package-3\n- package-4\n- package-5 (${chalk.red("private")}`);
calls++;
});

Expand Down Expand Up @@ -194,7 +195,7 @@ describe("UpdatedCommand", () => {
let calls = 0;
stub(logger, "info", (message) => {
if (calls === 0) assert.equal(message, "Checking for updated packages...");
if (calls === 2) assert.equal(message, "- package-1\n- package-2\n- package-3\n- package-4");
if (calls === 2) assert.equal(message, `- package-1\n- package-2\n- package-3\n- package-4\n- package-5 (${chalk.red("private")}`);
calls++;
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "package-5",
"version": "1.0.0",
"private": "true",
"dependencies": {
"package-1": "^1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "package-5",
"version": "1.0.0",
"private": "true",
"dependencies": {
"package-1": "^1.0.0"
}
}

0 comments on commit f325820

Please sign in to comment.