mirror of
https://github.com/chenasraf/simple-scaffold.git
synced 2026-05-17 17:28:09 +00:00
Update README.md
This commit is contained in:
31
README.md
31
README.md
@@ -14,15 +14,15 @@ yarn global add simple-scaffold
|
||||
```
|
||||
|
||||
## Use as a command line tool
|
||||
#### Command line options
|
||||
### Command line options
|
||||
|
||||
```bash
|
||||
simple-scaffold MyComponent --template scaffolds/component \
|
||||
simple-scaffold MyComponent --template scaffolds/component/**/* \
|
||||
--output src/components \
|
||||
--locals myProp="propname",myVal=123
|
||||
```
|
||||
|
||||
##### `--template`
|
||||
##### `--template glob [--template glob2 [...]]`
|
||||
A glob pattern of template files to load.
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ A template file may be of any type and extension, and supports [Handlebars](http
|
||||
|
||||
You may load more than one template list by simple adding more `--template` arguments.
|
||||
|
||||
##### `--output`
|
||||
##### `--output path`
|
||||
The output directory to put the new files in. They will attempt to maintain their regular structure as they are found, if possible.
|
||||
|
||||
Your new scaffold will be placed under a directory with the scaffold name from the argumemts.
|
||||
@@ -38,10 +38,23 @@ Your new scaffold will be placed under a directory with the scaffold name from t
|
||||
You may also pass a function to transform the output path for each file individually.
|
||||
This function takes 2 arguments: filename, and base glob path
|
||||
|
||||
##### `--locals`
|
||||
You may set local variables to be pushed into the template and replaced.
|
||||
The format for the value of this argument is:
|
||||
##### `--locals key=value[,key=value[,...]]`
|
||||
Pass a KV map to the template for parsing.
|
||||
|
||||
```
|
||||
property=value[,property=value[,...]]
|
||||
### Use in Node.js
|
||||
You can also build the scaffold yourself.
|
||||
Simply pass a config object to the constructor, and invoke `run()` when you are ready to start.
|
||||
The config takes the same arguments as the command line:
|
||||
|
||||
```javascript
|
||||
const SimpleScaffold = require('simple-scaffold').default
|
||||
|
||||
const scaffold = new SimpleScaffold({
|
||||
name: 'component',
|
||||
templates: [path.join(__dirname, 'scaffolds', 'component')],
|
||||
output: path.join(__dirname, 'src', 'components'),
|
||||
locals: {
|
||||
property: 'value',
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user