Skip to content

Commit 5e62b38

Browse files
committed
refactor: remove post-load-plugins, close #287, close #286, close #275
1 parent 33ffa69 commit 5e62b38

3 files changed

Lines changed: 12 additions & 34 deletions

File tree

package.json

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"make-dir": "^3.0.0",
4040
"meow": "^5.0.0",
4141
"path-exists": "^4.0.0",
42-
"post-load-plugins": "0.0.24",
4342
"posthtml": "^0.11.4",
4443
"to-camel-case": "^1.0.0"
4544
},
@@ -64,8 +63,7 @@
6463
"eslint-config-xo-space": "^0.21.0",
6564
"eslint-plugin-ava": "^7.1.0",
6665
"eslint-plugin-babel": "^5.3.0",
67-
"eslint-plugin-dependencies": "^2.4.0",
68-
"eslint-plugin-html": "^5.0.5",
66+
"eslint-plugin-html": "^6.0.0",
6967
"eslint-plugin-import": "^2.18.0",
7068
"eslint-plugin-markdown": "^1.0.0",
7169
"eslint-plugin-node": "^9.1.0",
@@ -123,26 +121,6 @@
123121
"posthtml": {
124122
"customElements": {}
125123
},
126-
"eslintConfig": {
127-
"parser": "babel-eslint",
128-
"plugins": [
129-
"dependencies",
130-
"html",
131-
"ava",
132-
"unicorn",
133-
"babel",
134-
"markdown"
135-
],
136-
"extends": [
137-
"plugin:unicorn/recommended",
138-
"plugin:ava/recommended",
139-
"xo",
140-
"xo-space"
141-
],
142-
"rules": {
143-
"capitalized-comments": "off"
144-
}
145-
},
146124
"clinton": {
147125
"ignores": [
148126
"test/**",

readme.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ $ posthtml --help
3737
```
3838
>**Note:** This package does not respect the order of patterns. First, all the negative patterns are applied, and only then the positive patterns.
3939
40-
> **Note:** Automatically loads plug-ins with configuration from package.json using [post-load-plugins](https://github.com/post-org/post-load-plugins) if not used `--auto-off` key
41-
4240
Also note that in case of using external config file, the config itself needs to be contained inside "posthtml" key:
4341
```js
4442
module.exports = {

src/cli.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import fg from 'fast-glob';
66
import meow from 'meow';
77
import makeDir from 'make-dir';
88
import posthtml from 'posthtml';
9-
import load from 'post-load-plugins';
109
import outResolve from './out-resolve';
1110
import cfgResolve from './cfg-resolve';
1211

@@ -18,7 +17,6 @@ const cli = meow(`
1817
--config -c Path to config file
1918
--use -u PostHTML plugin name
2019
--help -h CLI Help
21-
--auto-off Disable automatically loads plug-ins with configuration from package.json
2220
--version -v CLI Version
2321
2422
Examples:
@@ -54,25 +52,29 @@ const cli = meow(`
5452
}
5553
});
5654

57-
const read = file => new Promise(resolve => fs.readFile(file, 'utf8', (err, data) => {
58-
if (err) {
59-
console.warn(err);
55+
const read = file => new Promise(resolve => fs.readFile(file, 'utf8', (error, data) => {
56+
if (error) {
57+
console.warn(error);
6058
}
59+
6160
resolve(data);
6261
}));
6362

6463
const processing = async file => {
6564
const output = await outResolve(file, cli.flags.output);
6665
const config = await cfgResolve(cli.flags);
66+
const plugins = Object.keys(config.plugins || {})
67+
.map(plugin => require(plugin)(config.plugins[plugin]));
6768

6869
makeDir(path.dirname(output))
6970
.then(read.bind(null, file))
70-
.then(html => posthtml(load(config)).process(html))
71+
.then(html => posthtml(plugins).process(html))
7172
.then(({html}) => {
72-
fs.writeFile(output, html, err => {
73-
if (err) {
74-
console.warn(err);
73+
fs.writeFile(output, html, error => {
74+
if (error) {
75+
console.warn(error);
7576
}
77+
7678
console.log(`The file ${file} has been saved!`);
7779
});
7880
});

0 commit comments

Comments
 (0)