Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Imperative config building #25

@luvies

Description

@luvies

might be interesting to provide functions for building Takefile config object imperatively, so it more closely resembles jake. example:

const conf = take.startConfig();

// default target
conf.target(async () => {
  console.log('default target');
});

// 'target1', depends on 'target2'
conf.target('target1', ['target2'], async () => {
  await take.exec('echo 1');
});

// 'target2'
conf.target('target2', async () => {
  await take.exec('echo 2');
});

return conf.build();

i personally won't use this functionality, since i prefer the declarative method, it might be a good feature after full release. this also could lend itself to namespacing like so:

// namespace 'ns'
conf.namespace('ns', () => {
  // default target in 'ns' (i.e. called using 'ns')
  conf.target(() => {
    console.log('default target');
  });

  // 'ns:child1'
  conf.target('child1', () => {
    console.log('this target is at :ns:child1');
  });
});

this would essentially be wrapper methods that would produce the config object as the end result, rather than any different implementation, but it might be worth implementing at some point. the only problem would be in supporting the same level of configurability that the declarative-based method supports, but it would likely be done by allowing objects to be passed in that have the same properties as the config object.

Metadata

Metadata

Assignees

Labels

featureNew feature or large change

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions