Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP: Add
prependPath
option to listFiles
method (#462)
## What? Add `prependPath` option to `PHP.listFiles` method, which will prepend given folder path to every file found in it. ## Why? It's a common need to iterate over a list of files with each file path being an accessible path instead of only the file name. Idea mentioned in: - WordPress/wordpress-playground#427 (comment) For example, this is a common pattern: ```ts const files = await playground.listFiles( folderPath ) for (const file of files) { const filePath = `${folderPath}/${file}`; ... } ``` Also expressed as: ```ts const filePaths = (await playground.listFiles( folderPath )).map( (name: string) => `${folderPath}/${name}`) ) ``` With the new option, the above can be simplified as: ```ts const filePaths = await playground.listFiles(folderPath, { prependPath: true }) ``` ## How? - [x] Add `prependPath` option to `BasePHP.listFiles` method - [x] Document the option and what it does - [x] Add test ## Testing Instructions <!-- Please include step by step instructions on how to test this PR. --> 1. Check out the branch. 2. Run `nx test playground-blueprints`
- Loading branch information