beelzebub
Version:
One Hell of a Task Master!
74 lines (61 loc) • 1.42 kB
JavaScript
;
// !-- FOR TESTS
let wrapper = function (options) {
// --!
// =====================================================
// <EXAMPLE>
let Beelzebub = require('../../');
let bz = Beelzebub(options || { verbose: true });
class MyBaseTasks extends Beelzebub.Tasks {
constructor (config) {
super(config);
this.$setName('MyBaseTasks');
}
task1 () {
this.logger.log('MyBaseTasks task1');
}
task2 () {
this.logger.log('MyBaseTasks task2');
}
task2Option () {
this.logger.log('MyBaseTasks task2 option');
}
_internalFunction () {
this.logger.error('this should be ignored');
}
}
Beelzebub.add(MyBaseTasks);
class MyTasks extends MyBaseTasks {
constructor (config) {
super(config);
this.$setName('MyTasks');
}
task1 () {
this.logger.log('MyTasks task1');
}
task3 () {
this.logger.log('MyTasks task3');
}
}
bz.add(MyTasks);
let p = bz.run(
'MyTasks.task1',
'MyTasks.task3',
'MyTasks.task2',
'MyTasks.task2Option'
);
/* Output:
MyTasks task1
MyTasks task3
MyBaseTasks task2
MyBaseTasks task2 option
*/
// </EXAMPLE>
// =====================================================
// !-- FOR TESTS
return p.then(() => { return bz; });
};
module.exports = wrapper;
// if not running in test, then run wrapper
if (typeof global.it !== 'function') wrapper();
// --!