Skip to content

Commit ffa9910

Browse files
committed
Add PluginAPI.commandHistory
1 parent cc16b6c commit ffa9910

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

docs/docs.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,10 @@ Runs the nodemiral task list, and returns a promise. If any of the tasks fail, i
11931193

11941194
Returns a promise. Shows the logs to the user, prefixing the host to each line.
11951195

1196+
#### **commandHistory**
1197+
1198+
Array of objects. Each object is in the format of `{name: 'plugin.commandName'}`, and shows what commands have already been run and in what order.
1199+
11961200
#### **runSSHCommand(server, command)**
11971201
server is an object from `servers` in the config
11981202

src/__tests__/plugin-api.unit.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ describe('PluginAPI', () => {
4646
it('should have "program"', () => {
4747
expect(api).has.property('program');
4848
});
49+
it('should have "commandHistory"', () => {
50+
expect(api).has.property('commandHistory');
51+
});
4952
});
5053
describe('utils', () => {
5154
it('should have resolvePath', () => {
@@ -244,6 +247,11 @@ describe('PluginAPI', () => {
244247
console.log(e);
245248
});
246249
});
250+
251+
it('should update commandHistory', () => {
252+
api.runCommand('test.logs');
253+
expect(api.commandHistory).to.deep.equal([{name: 'test.logs'}]);
254+
});
247255
});
248256

249257
describe('getSessions', () => {

src/plugin-api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class PluginAPI {
3030
this.settingsPath = program.settings;
3131
this.verbose = program.verbose;
3232
this.program = program;
33+
this.commandHistory = [];
3334

3435
this.validationErrors = [];
3536

@@ -263,7 +264,7 @@ export default class PluginAPI {
263264
// Only show error when not from nodemiral
264265
// since nodemiral would have already shown the error
265266
if (!(e.nodemiralHistory instanceof Array)) {
266-
log('_commandErrorHandler: nodemiral error');
267+
log('_commandErrorHandler: nodemiral error');
267268
console.error(e.stack || e);
268269
}
269270

@@ -281,6 +282,9 @@ export default class PluginAPI {
281282
if (!(name in commands)) {
282283
throw new Error(`Unknown command name: ${name}`);
283284
}
285+
286+
this.commandHistory.push({ name });
287+
284288
await this._runPreHooks(name);
285289
let potentialPromise;
286290
try {

0 commit comments

Comments
 (0)