Comments (8)
I created a custom action type to add data to my config.json file.
Tried to follow the plop style to keep it customizable.
https://gist.github.com/mritzco/88306b56c0184e66e33374d6b6ed2751
from plop.
I went ahead and made a custom action for this, but I definitely think this could get rolled in as a flag on modify
action types or a new action type altogether. Here's the code for alterJsonAction.js: https://gist.github.com/wbobeirne/63e1b8c3a16ffce6dac5c7d81afd5cec?ts=2
Example usage from my use case is:
const alterJsonAction = require("alterJsonAction");
actions: [alterJsonAction({
path: "../webpack/entries.json",
alter: (json, data) => {
const name = snakeCase(data.name);
json[data.platform][name] = `pages/${name}`;
return json;
},
})],
I also threw in an indentation
arg there that takes an int or "\t", if 2 spaces ain't your game.
from plop.
sorry for the late response, I agree that this would be pretty useful in some cases. I'll have to give some more thought to the best implementation for this feature. Thanks!
from plop.
hey, with plop 1.8.0 you can now create custom action types that you can share with other projects :-)
from plop.
nice! You could publish this out as an NPM module that others can use via plop.load(). If you want to do that and need help, let me know.
from plop.
I'll happily do! Just publish to npm or any specific requirements?
from plop.
Sorry for the delay on this response. You can look at this repo as a guide to how this is done. I'm going to try to get more instructional content together soon.
from plop.
@amwmedia
Ok, that took a bit longer than expected:
Could you please take a look at this repo and let me know if that would do.
Original method gets the config on the method call, while the load method passes the config on the require function. It's working with the testing file but I'm not sure it will work properly in all cases.
from plop.
Related Issues (20)
- Support multiple component generation in one go using whitespaces as a delimiter
- Plop does not handle `| null` when adding lines HOT 1
- Feature request: ability to use `select` prompt from Inquirer HOT 2
- Rewrite to use new Inquirer Packages HOT 1
- Plop is not a function HOT 2
- SyntaxError: Identifier 'require' has already been declared HOT 1
- No plopfile found! - message after compilation in procedural script HOT 2
- [node-plop] Support ESM configs HOT 4
- Helpers in Template Files HOT 1
- feat: make it possible to disable the progress spinner HOT 1
- Loaded plopfiles do not respect the `--force` flag HOT 6
- Plop 4 Planning HOT 6
- Set `dest` dynamically within a monorepo (workspace) environment HOT 6
- Add configuration option for custom handlebar delimiters HOT 3
- [node-plop] instanceof Array is not working with array from vm script
- Action `type: "modify"`'s `pattern` property should be built as a Handlebars template HOT 1
- node v14๏ผIntl.Segmenter is not a constructor HOT 1
- titleCase fails to transform name HOT 2
- Supporting plopfile.ts .ts extension HOT 5
- Action type that trigger shell command HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plop.