From 41d879931d57f818b6e4efe3d1ea5385f52e2a4c Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 3 May 2020 15:28:06 +0200 Subject: [PATCH] packages/cli: clearer plugin:diff output for package.json + fix --- packages/cli/src/commands/plugin/diff/handlers.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/plugin/diff/handlers.ts b/packages/cli/src/commands/plugin/diff/handlers.ts index 11af6ff42c..df7ca081de 100644 --- a/packages/cli/src/commands/plugin/diff/handlers.ts +++ b/packages/cli/src/commands/plugin/diff/handlers.ts @@ -66,9 +66,10 @@ class PackageJsonHandler { prefix?: string, ) { const fullFieldName = chalk.cyan( - prefix ? `${prefix}[${fieldName}]` : prefix, + prefix ? `${prefix}[${fieldName}]` : fieldName, ); const newValue = obj[fieldName]; + const coloredNewValue = chalk.cyan(JSON.stringify(newValue)); if (fieldName in targetObj) { const oldValue = targetObj[fieldName]; @@ -76,9 +77,8 @@ class PackageJsonHandler { return; } - const msg = - `Outdated field, ${fullFieldName}, change from ` + - `${chalk.cyan(oldValue)} to ${chalk.cyan(newValue)}?`; + const coloredOldValue = chalk.cyan(JSON.stringify(oldValue)); + const msg = `package.json has mismatched field, ${fullFieldName}, change from ${coloredOldValue} to ${coloredNewValue}?`; if (await this.prompt(msg)) { targetObj[fieldName] = newValue; await this.write(); @@ -86,7 +86,7 @@ class PackageJsonHandler { } else { if ( await this.prompt( - `Missing field ${fullFieldName}, set to ${chalk.cyan(newValue)}?`, + `package.json is missing field ${fullFieldName}, set to ${coloredNewValue}?`, ) ) { targetObj[fieldName] = newValue;