@oclif/core 2.6.4 → 2.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/command.js +9 -4
- package/lib/help/util.js +1 -1
- package/package.json +1 -1
package/lib/command.js
CHANGED
|
@@ -157,16 +157,21 @@ class Command {
|
|
|
157
157
|
}
|
|
158
158
|
warnIfFlagDeprecated(flags) {
|
|
159
159
|
for (const flag of Object.keys(flags)) {
|
|
160
|
-
const
|
|
160
|
+
const flagDef = this.ctor.flags[flag];
|
|
161
|
+
const deprecated = flagDef?.deprecated;
|
|
161
162
|
if (deprecated) {
|
|
162
163
|
this.warn((0, util_2.formatFlagDeprecationWarning)(flag, deprecated));
|
|
163
164
|
}
|
|
164
|
-
const deprecateAliases =
|
|
165
|
-
const aliases = (
|
|
165
|
+
const deprecateAliases = flagDef?.deprecateAliases;
|
|
166
|
+
const aliases = (flagDef?.aliases ?? []).map(a => a.length === 1 ? `-${a}` : `--${a}`);
|
|
166
167
|
if (deprecateAliases && aliases.length > 0) {
|
|
167
168
|
const foundAliases = aliases.filter(alias => this.argv.some(a => a.startsWith(alias)));
|
|
168
169
|
for (const alias of foundAliases) {
|
|
169
|
-
|
|
170
|
+
let preferredUsage = `--${flagDef?.name}`;
|
|
171
|
+
if (flagDef?.char) {
|
|
172
|
+
preferredUsage += ` | -${flagDef?.char}`;
|
|
173
|
+
}
|
|
174
|
+
this.warn((0, util_2.formatFlagDeprecationWarning)(alias, { to: preferredUsage }));
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
177
|
}
|
package/lib/help/util.js
CHANGED
|
@@ -101,7 +101,7 @@ function formatFlagDeprecationWarning(flag, opts) {
|
|
|
101
101
|
if (opts.version) {
|
|
102
102
|
message += ` and will be removed in version ${opts.version}`;
|
|
103
103
|
}
|
|
104
|
-
message += opts.to ? `. Use "
|
|
104
|
+
message += opts.to ? `. Use "${opts.to}" instead.` : '.';
|
|
105
105
|
return message;
|
|
106
106
|
}
|
|
107
107
|
exports.formatFlagDeprecationWarning = formatFlagDeprecationWarning;
|