-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added otable formatter * make core options more consistent in grammar
- Loading branch information
Showing
4 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,14 @@ | |
### New Features | ||
|
||
* Added `examples`, `positional`, and `usage` `yargs` parsing to incomings tasks | ||
* Added new `oclif` style tabling option | ||
|
||
### Internals | ||
|
||
* Added `yargs` to task middleware | ||
* Added `appConfig` to `lando` for more powerful tasks | ||
* Added `primary` to `appConfig` for more powerful tasks | ||
* Added `otable` to `formatData` | ||
* Updated to `[email protected]` for better `--` handling | ||
|
||
## v3.21.2 - [June 20, 2024](https://github.com/lando/cli/releases/tag/v3.21.2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
/* | ||
* Returns an array of all keys, nested or otherwise, as "." separated paths but does not expand arrays | ||
* @TODO: implement depth? this is needed for upstream things like get-object-size? | ||
*/ | ||
module.exports = (data, {prefix = '', expandArrays = true, separator = '.'} = {}) => { | ||
return Object.keys(data).reduce((keys, key) => { | ||
// if we have a primitive then return the path | ||
if (!data[key] || typeof data[key] !== 'object' || Object.keys(data[key]).length === 0) { | ||
return !key.includes(separator) ? [...keys, `${prefix}${key}`] : [...keys, `${prefix}["${key}"]`]; | ||
} | ||
|
||
// if we arent expanding arrays then dont return paths with array indexes | ||
if (!expandArrays && Array.isArray(data[key])) { | ||
return [...keys, `${prefix}${key}`]; | ||
} | ||
|
||
// otherwise cycle through again | ||
return [...keys, ...module.exports(data[key], {expandArrays, prefix: `${prefix}${key}${separator}`})]; | ||
}, []); | ||
}; |