f / f/omelette
Suggestion: Let .tree() accept callbacks
- Dominant language
- CoffeeScript
- Stars
- 1.4k
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
I love `.tree()` because it can represent nested dependencies:
```js
omelette('hello').tree({
cruel: ['world', 'moon'],
beautiful: ['mars', 'pluto']
}).init();
```
However, it’d be great if it were possible to also dynamically create the top level via a callback:
```js
omelette('hello').tree(
async () => {
const json = await /* ... */;
return json;
}
).init();
```
In my own code, I use the following workaround (TypeScript code):
```ts
const oml = omelette(BIN_NAME) as omelette.Instance & { compgen: number };
if (oml.compgen >= 0) {
const tree: omelette.TreeValue = {};
const projectDir = process.cwd();
if (BookConfig.isProjectDir(projectDir)) {
const bookConfig = BookConfig.fromDir(projectDir);
for (const key of bookConfig.getOutputConfigKeys()) {
tree[key] = ['--dry-run', '--replace'];
}
}
oml.tree(tree).init();
return; // not really needed
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.