-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#25: Move command removal to LandoOclifPlugin
- Loading branch information
Showing
4 changed files
with
57 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,50 @@ | ||
const OclifPlugin = require('@oclif/config').Plugin; | ||
|
||
class LandoOclifPlugin extends OclifPlugin { | ||
constructor(config, replace) { | ||
super(config); | ||
this.replace = replace; | ||
} | ||
// constructor(config) { | ||
// super(config); | ||
// // this.replace = replace; | ||
// } | ||
|
||
get hooks() { | ||
return {}; | ||
} | ||
// @TODO: this should handle a string id or an array of ids to be removed | ||
removeCommand(cmdId) { | ||
// remove command logic here | ||
// @NOTE: this is not namespaced in a useful way until load is run | ||
|
||
get topics() { | ||
return []; | ||
const commandIndex = this.commands.findIndex(({id}) => id === cmdId); | ||
if (commandIndex === -1) { | ||
this._debug('could not find a command called %s in plugin %s, doing nothing', cmdId, this.name); | ||
return this.commands; | ||
} | ||
this.commands.splice(commandIndex, 1); | ||
this._debug('removed command %s: plugin now has commands %o', cmdId, this.commands.map(command => command.id)); | ||
return this.commands; | ||
} | ||
|
||
// @TODO: do we need this? | ||
get commandIDs() { | ||
return [this.replace.id]; | ||
} | ||
// @TODO: we need to make sure that when we reinstantiate @lando/hyperdrive that this | ||
// gets the list of hooks correctly, otherwise is set to {} | ||
|
||
// get hooks() { | ||
// return {}; | ||
// } | ||
|
||
// get topics() { | ||
// return []; | ||
// } | ||
|
||
// // @TODO: do we need this? | ||
// get commandIDs() { | ||
// return [this.replace.id]; | ||
// } | ||
|
||
/* | ||
get commands() { | ||
const cmd = require(this.replace.path); | ||
cmd.id = this.replace.id; | ||
cmd.load = () => cmd; | ||
return [cmd]; | ||
} | ||
*/ | ||
} | ||
|
||
module.exports = LandoOclifPlugin; |