use
pnpm create
/yarn create
/npm init
with yeoman generator
$ pnpm add create-with-generator
require('create-with-generator').runGenerator({ __dirname })
key | type | required | description |
---|---|---|---|
__dirname |
string |
true |
your __dirname , used to detect who is calling runGenerator , if running in a symlinked environment, you need pass __dirname explicitly |
name |
string |
false |
generator name, can be bareName(like augular or @scope/augular ) or fullname name(like generator-angular or @scope/generator-angular ) |
subname |
string |
false |
generator subname, defaults empty, stands for yo <name>:app |
example we have generator-angular
, and we want to build the create-angular
package
- init package.json via
npm init
- install deps:
pnpm add create-with-generator 'generator-angular@*'
- add
index.js
with contents below - add
main
&bin
field of package.json toindex.js
- tweak your package.json as you want, then run
npm publish
- start create using
pnpm create angular
require('create-with-generator').runGenerator({ __dirname })
{
"main": "index.js",
"bin": "index.js"
}
the MIT License http://magicdawn.mit-license.org