@oclif/plugin-commands
Advanced tools
Comparing version 4.0.16 to 4.0.17
@@ -34,2 +34,8 @@ import { Command, Flags, toConfiguredId } from '@oclif/core'; | ||
} | ||
// In order to collect static properties up the inheritance chain, we need to recursively access the prototypes until there's nothing left | ||
function mergePrototype(result, command) { | ||
const proto = Object.getPrototypeOf(command); | ||
const filteredProto = _.pickBy(proto, (v) => v !== undefined); | ||
return Object.keys(proto).length > 0 ? mergePrototype({ ...filteredProto, ...result }, proto) : result; | ||
} | ||
export default class Commands extends Command { | ||
@@ -118,12 +124,5 @@ static description = 'List all <%= config.bin %> commands.'; | ||
this.debug(error); | ||
return cmd; | ||
} | ||
const obj = { ...cmd, ...commandClass }; | ||
// Load all properties on all extending classes. | ||
while (commandClass !== undefined) { | ||
commandClass = Object.getPrototypeOf(commandClass) ?? undefined; | ||
// ES2022 will return all unset static properties on the prototype as undefined. This is different from ES2021 | ||
// which only returns the static properties that are set by defaults. In order to prevent | ||
// Object.assign from overwriting the properties on the object, we need to filter out the undefined values. | ||
Object.assign(obj, _.pickBy(commandClass, (v) => v !== undefined)); | ||
} | ||
const obj = { ...mergePrototype(commandClass, commandClass), ...cmd }; | ||
// The plugin property on the loaded class contains a LOT of information including all the commands again. Remove it. | ||
@@ -130,0 +129,0 @@ delete obj.plugin; |
@@ -108,3 +108,3 @@ { | ||
}, | ||
"version": "4.0.16" | ||
"version": "4.0.17" | ||
} |
{ | ||
"name": "@oclif/plugin-commands", | ||
"description": "plugin to show the list of all the commands", | ||
"version": "4.0.16", | ||
"version": "4.0.17", | ||
"author": "Salesforce", | ||
@@ -33,3 +33,3 @@ "bugs": "https://github.com/oclif/plugin-commands/issues", | ||
"nyc": "^15.1.0", | ||
"oclif": "^4.14.34", | ||
"oclif": "^4.14.35", | ||
"prettier": "^3.3.3", | ||
@@ -36,0 +36,0 @@ "shx": "^0.3.3", |
@@ -24,3 +24,3 @@ # @oclif/plugin-commands | ||
$ oclif-example (--version) | ||
@oclif/plugin-commands/4.0.16 linux-x64 node-v20.17.0 | ||
@oclif/plugin-commands/4.0.17 linux-x64 node-v20.17.0 | ||
$ oclif-example --help [COMMAND] | ||
@@ -65,3 +65,3 @@ USAGE | ||
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v4.0.16/src/commands/commands.ts)_ | ||
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v4.0.17/src/commands/commands.ts)_ | ||
<!-- commandsstop --> | ||
@@ -68,0 +68,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16150
300