Skip to content

Commit a3a77e2

Browse files
author
Chen Asraf
committed
Update README.md
1 parent f360159 commit a3a77e2

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,47 @@ yarn global add simple-scaffold
1414
```
1515

1616
## Use as a command line tool
17-
#### Command line options
17+
### Command line options
1818

1919
```bash
20-
simple-scaffold MyComponent --template scaffolds/component \
20+
simple-scaffold MyComponent --template scaffolds/component/**/* \
2121
--output src/components \
2222
--locals myProp="propname",myVal=123
2323
```
2424

25-
##### `--template`
25+
##### `--template glob [--template glob2 [...]]`
2626
A glob pattern of template files to load.
2727

2828

2929
A template file may be of any type and extension, and supports [Handlebars](https://handlebarsjs.com) as a parsing engine for the file names and contents, so you may customize both with variables from your configuration.
3030

3131
You may load more than one template list by simple adding more `--template` arguments.
3232

33-
##### `--output`
33+
##### `--output path`
3434
The output directory to put the new files in. They will attempt to maintain their regular structure as they are found, if possible.
3535

3636
Your new scaffold will be placed under a directory with the scaffold name from the argumemts.
3737

3838
You may also pass a function to transform the output path for each file individually.
3939
This function takes 2 arguments: filename, and base glob path
4040

41-
##### `--locals`
42-
You may set local variables to be pushed into the template and replaced.
43-
The format for the value of this argument is:
44-
45-
```
46-
property=value[,property=value[,...]]
41+
##### `--locals key=value[,key=value[,...]]`
42+
Pass a KV map to the template for parsing.
43+
44+
### Use in Node.js
45+
You can also build the scaffold yourself.
46+
Simply pass a config object to the constructor, and invoke `run()` when you are ready to start.
47+
The config takes the same arguments as the command line:
48+
49+
```javascript
50+
const SimpleScaffold = require('simple-scaffold').default
51+
52+
const scaffold = new SimpleScaffold({
53+
name: 'component',
54+
templates: [path.join(__dirname, 'scaffolds', 'component')],
55+
output: path.join(__dirname, 'src', 'components'),
56+
locals: {
57+
property: 'value',
58+
}
59+
})
4760
```

0 commit comments

Comments
 (0)