Skip to content

Commit 068f540

Browse files
author
Ivan Demidov
committed
Fixed #41, update load pkg
1 parent aa59887 commit 068f540

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

README.md

+19-12
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,37 @@ npm install --global posthtml-cli
1515
```console
1616
$ posthtml --help
1717

18-
Usage
18+
Usage
1919
posthtml --output|-o output.html --input|-i input.html [--config|-c path/to/json/config]
2020

21-
Options
21+
Options
2222
--config, -c Path to JSON file [string]
2323
--output, -o Output html file result [required]
2424
--input, -i Input html file [required]
2525
--help, -h Show help [boolean]
2626
--version, -v Show version number [boolean]
27-
28-
Example
27+
28+
Example
2929
posthtml -o output.html -i input.html
3030
```
3131

32-
*Default read config in package.json*
32+
For reading config used [posthtml-load-plugins](https://github.com/michael-ciniawsky/posthtml-load-plugins)
33+
*Default read options for plugins from package.json*
3334
```json
3435
{
35-
"name": "my project",
36-
"posthtml": {
37-
"require": ["posthtml-custom-elements"]
38-
},
39-
"posthtml-custom-elements": {
40-
"defaultTag": "span"
41-
}
36+
"name": "my project",
37+
"devDependencies": {
38+
"posthtml-custom-elements": "^1.0.3",
39+
"posthtml-style-to-file": "^0.1.1"
40+
},
41+
"posthtml": {
42+
"customElements": {
43+
"defaultTag": "span"
44+
},
45+
"styleToFile": {
46+
"path": "./dist/style.css"
47+
}
48+
}
4249
}
4350
```
4451

cli.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,8 @@ var argv = require('yargs')
2222
// get htmls
2323
var html = fs.readFileSync(argv.input, 'utf8');
2424

25-
// get plugins
26-
var plugins = [];
27-
if (argv.require) {
28-
plugins = argv.require.map(function (name) {
29-
return require(name)(argv[name]);
30-
});
31-
}
32-
3325
// processing
34-
posthtml(plugins)
26+
posthtml(require('posthtml-load-plugins')(argv.config))
3527
.process(html)
3628
.then(function (result) {
3729
fs.writeFileSync(argv.output, result.html);

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"homepage": "https://github.com/GitScrum/posthtml-cli#readme",
2727
"dependencies": {
2828
"posthtml": "^0.8.3",
29+
"posthtml-load-plugins": "^0.9.1",
2930
"yargs": "^4.3.1"
3031
},
3132
"devDependencies": {
@@ -40,8 +41,6 @@
4041
"xo": "^0.13.0"
4142
},
4243
"posthtml": {
43-
"require": [
44-
"posthtml-custom-elements"
45-
]
44+
"posthtmlCustomElements": {}
4645
}
4746
}

test/fixtures/config.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"require": ["posthtml-custom-elements"],
3-
"posthtml-custom-elements": {
2+
"customElements": {
43
"defaultTag": "span"
54
}
65
}

0 commit comments

Comments
 (0)