Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relative tasks not working with root tasks #47

Open
jstty opened this issue Jul 24, 2017 · 1 comment
Open

relative tasks not working with root tasks #47

jstty opened this issue Jul 24, 2017 · 1 comment

Comments

@jstty
Copy link
Owner

jstty commented Jul 24, 2017

No description provided.

@jstty
Copy link
Owner Author

jstty commented Jul 24, 2017

Example:

'use strict';
// !-- FOR TESTS
let wrapper = function (options) {
// --!

// =====================================================
// <EXAMPLE>
  let Beelzebub = require('../../');
  let bz = Beelzebub(options || { verbose: true });

  class MySubTask extends Beelzebub.Tasks {
    default () {
      this.logger.log('MySubTask default');
      return this.$sequence('.task1', '.task2');
    }

    task1 () {
      this.logger.log('MySubTask task1');
    }

    task2 () {
      this.logger.log('MySubTask task2');
    }
  }

  class MyTasks extends Beelzebub.Tasks {
    constructor (config) {
      super(config);

      this.$setDefault('myDefault');
    }

    myDefault () {
      this.logger.log('MyTasks myDefault');
    }
  }

  class MyRootLevel extends Beelzebub.Tasks {
    constructor (config) {
      super(config);

      this.$useAsRoot();
    }

    $init () {
      this.$addSubTasks(MySubTask);
    }

    task1 () {
      this.logger.log('MyRootLevel task1');
    }

    task2 () {
      this.logger.log('MyRootLevel task2');
    }
  }

  bz.add(MyRootLevel);
  bz.add(MyTasks);

  let p = bz.run(
    'task1',
    'MySubTask',
    'MySubTask.task1',
    'MyTasks',
    'MyTasks.myDefault'
  );
/* Output:
MyRootLevel task1
MySubTask default
MySubTask task1
MySubTask task2
MySubTask task1
MyTasks myDefault
MyTasks myDefault
*/
// </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();
// --!

@jstty jstty changed the title (bug) relative tasks not working with root tasks relative tasks not working with root tasks Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant