Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight private packages in updated/publish output #436

Merged
merged 3 commits into from
Dec 14, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -231,7 +232,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")})` : ""}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sees nicer to have it at the end like this. 👍

}).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"
}
}