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

Update plop.load docs regarding async/await requirement in es6 modules #378

Merged
merged 1 commit into from
Jun 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions plop-load.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plop.load
=========

`plop.load` can be used to load generators, actionTypes, helpers, and partials from a other plopfiles that are in your project or on NPM (`plop-pack`). Example code below.
`plop.load` can be used to load generators, actionTypes, helpers, and partials from a other plopfiles that are in your project or on NPM (`plop-pack`). `plop.load` executes async when used within es6 modules and requires `async/await`. Example code below.

### plop.load([targets](#targets), [[config](#config)], [[include](#include)])

Expand Down Expand Up @@ -30,6 +30,14 @@ If `include` is `true` all assets from the target will be included (none if `fal
- **Object:** the include object allows the consumer to rename assets when for use in their own plopfile. the property name in this object is the asset name, the value is the name that will be given to the asset when loaded.

## Examples
*Usage in es6 modules*
```javascript
// plop.load has to be within an async function
export default async function(plop) {
// Use await to actually load the external files
await plop.load('./plopfiles/component.js`);
}
```
*load via a path*
```javascript
// loads all 5 generators, no helpers, actionTypes or partials (even if they exist)
Expand Down Expand Up @@ -63,7 +71,6 @@ If `include` is `true` all assets from the target will be included (none if `fal
```javascript
// loads all 3 helpers
plop.load('plop-pack-fancy-comments');
};
```
*load via npm module with a renaming include config*
```javascript
Expand Down