Skip to content

Commit 4f4e453

Browse files
authored
Merge pull request #333 from posthtml/milestone-0.9.0
Milestone 0.9.0
2 parents ad6737c + 59bffb6 commit 4f4e453

File tree

14 files changed

+315
-550
lines changed

14 files changed

+315
-550
lines changed

ava.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export default {
2+
verbose: true,
3+
timeout: '1m',
24
files: ['test/test-*'],
35
require: [
46
"@babel/register"

changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
## 0.9.0 (2020-11-24)
2+
3+
* build: update dep dev ([41f89ec](https://github.com/posthtml/posthtml-cli/commit/41f89ec))
4+
* docs: description for skip parse, #332 ([3cb4612](https://github.com/posthtml/posthtml-cli/commit/3cb4612)), closes [#332](https://github.com/posthtml/posthtml-cli/issues/332)
5+
* feat: skip parse option, close #332 ([a77c7a1](https://github.com/posthtml/posthtml-cli/commit/a77c7a1)), closes [#332](https://github.com/posthtml/posthtml-cli/issues/332)
6+
* test: for skip options, issue #332 ([a1188b2](https://github.com/posthtml/posthtml-cli/commit/a1188b2)), closes [#332](https://github.com/posthtml/posthtml-cli/issues/332)
7+
8+
9+
110
## <small>0.8.1 (2020-11-17)</small>
211

12+
* 0.8.1 ([f103051](https://github.com/posthtml/posthtml-cli/commit/f103051))
313
* build: lock ([1b8dffc](https://github.com/posthtml/posthtml-cli/commit/1b8dffc))
14+
* build: update changelog ([597ab5c](https://github.com/posthtml/posthtml-cli/commit/597ab5c))
415
* fix: allInOutput config in JSON is ignored, close #330 ([236c902](https://github.com/posthtml/posthtml-cli/commit/236c902)), closes [#330](https://github.com/posthtml/posthtml-cli/issues/330)
516
* test: allInOutput config in JSON is ignored, issue #330 ([11d9fb7](https://github.com/posthtml/posthtml-cli/commit/11d9fb7)), closes [#330](https://github.com/posthtml/posthtml-cli/issues/330)
617

package-lock.json

Lines changed: 217 additions & 525 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posthtml-cli",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "CLI for posthtml",
55
"license": "MIT",
66
"repository": "posthtml/posthtml-cli",
@@ -18,12 +18,12 @@
1818
"node": ">=10"
1919
},
2020
"scripts": {
21-
"version": "conventional-changelog -i changelog.md -s -r 0 && git add changelog.md && git commit -m \"build: update changelog\"",
21+
"version": "conventional-changelog -i changelog.md -s -r 0 && git add changelog.md",
2222
"prepare": "npm run build",
2323
"build": "rimraf lib && babel src -d lib",
2424
"coverage": "nyc report --reporter=text-lcov | coveralls",
2525
"pretest": "npm run build",
26-
"test": "nyc ava --timeout=1m --verbose"
26+
"test": "nyc ava"
2727
},
2828
"files": [
2929
"lib/"
@@ -38,17 +38,17 @@
3838
"fast-glob": "^3.2.4",
3939
"make-dir": "^3.0.0",
4040
"meow": "^7.1.1",
41-
"merge-options": "^3.0.3",
41+
"merge-options": "^3.0.4",
4242
"normalize-path": "^3.0.0",
43-
"posthtml": "^0.13.3",
43+
"posthtml": "^0.15.0",
4444
"to-camel-case": "^1.0.0",
4545
"update-notifier": "^5.0.0"
4646
},
4747
"devDependencies": {
48-
"@babel/cli": "^7.11.6",
49-
"@babel/core": "^7.11.6",
48+
"@babel/cli": "^7.12.8",
49+
"@babel/core": "^7.12.8",
5050
"@babel/node": "^7.10.5",
51-
"@babel/preset-env": "^7.11.5",
51+
"@babel/preset-env": "^7.12.7",
5252
"@babel/register": "^7.11.5",
5353
"@commitlint/cli": "^11.0.0",
5454
"@commitlint/config-angular": "^11.0.0",
@@ -60,8 +60,8 @@
6060
"conventional-changelog-cli": "^2.1.0",
6161
"coveralls": "^3.0.9",
6262
"cpy": "^8.1.1",
63-
"eslint": "^7.11.0",
64-
"eslint-config-xo": "^0.32.1",
63+
"eslint": "^7.14.0",
64+
"eslint-config-xo": "^0.33.1",
6565
"eslint-config-xo-space": "^0.25.0",
6666
"eslint-plugin-ava": "^11.0.0",
6767
"eslint-plugin-babel": "^5.3.1",
@@ -70,12 +70,12 @@
7070
"eslint-plugin-markdown": "^1.0.1",
7171
"eslint-plugin-node": "^11.0.0",
7272
"eslint-plugin-promise": "^4.1.1",
73-
"eslint-plugin-unicorn": "^22.0.0",
73+
"eslint-plugin-unicorn": "^23.0.0",
7474
"execa": "^4.0.3",
7575
"husky": "^4.3.0",
7676
"is-promise": "^4.0.0",
77-
"lint-staged": "^10.4.0",
78-
"merge": "^1.2.1",
77+
"lint-staged": "^10.5.2",
78+
"merge": "^2.1.0",
7979
"nyc": "^15.0.0",
8080
"posthtml-bem": "^0.2.2",
8181
"posthtml-css-modules": "^0.1.3",

readme.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
> [PostHTML][posthtml-url] сommand line interface
44
5-
[![Actions Status](https://github.com/posthtml/posthtml-cli/workflows/Actions%20Status/badge.svg?style=flat-square)](https://github.com/posthtml/posthtml-cli/actions?query=workflow%3A%22CI+tests%22)[![node][node-image]][node-url][![NPM version][npm-image]][npm-url][![Dependency Status][depstat-image]][depstat-url][![XO code style][style]][style-url][![Coveralls Status][coveralls-image]][coveralls-url]
5+
[![Actions Status](https://github.com/posthtml/posthtml-cli/workflows/Actions%20Status/badge.svg?style=flat-square)](https://github.com/posthtml/posthtml-cli/actions?query=workflow%3A%22CI+tests%22)[![node][node-image]][node-url][![NPM version][npm-image]][npm-url][![XO code style][style]][style-url][![Coveralls Status][coveralls-image]][coveralls-url]
66

7-
[![npm downloads][npm-download-image]][npm-download-url][![npm][npm-total-download-image]][npm-total-download-url][![Package Quality][pkg-q-image]][pkg-q-url]
7+
[![npm downloads][npm-download-image]][npm-download-url][![npm][npm-total-download-image]][npm-total-download-url]
88

99
## Install
1010

@@ -28,6 +28,7 @@ $ posthtml --help
2828
--use -u PostHTML plugin name
2929
--root -r Mirror the directory structure relative to this path in the output directory(default: .)
3030
--allInOutput -a Save the nesting structure for output
31+
--skip -s Skip parsing file
3132
--help -h CLI Help
3233
--version -v CLI Version
3334

@@ -36,6 +37,7 @@ $ posthtml --help
3637
$ posthtml input.html -o output.html
3738
$ posthtml inputFolder/*.html !unicorn.html
3839
$ posthtml '**/*.html' '\!**/unicorn.html'
40+
$ posthtml '**/*.html' -s unicorn.html
3941
$ posthtml input-one.html input-two.html -o outputFolder
4042
$ posthtml input.html -o output.html -c posthtml.js
4143
$ posthtml input.html -o output.html -u posthtml-bem --posthtml-bem.elemPrefix __
@@ -52,6 +54,7 @@ $ posthtml --help
5254
"root": "src",
5355
"input": "*.html",
5456
"output": "dist",
57+
"skip": ["skip.html", "file.html"]
5558
"options": {
5659
"sync": true,
5760
"directives": [{"name": "?php", "start": "<", "end": ">"}]
@@ -67,8 +70,6 @@ $ posthtml --help
6770
> example config _`.posthtmlrc`_
6871
6972
[posthtml-url]: http://github.com/posthtml/posthtml
70-
[pkg-q-url]: http://packagequality.com/#?package=posthtml-cli
71-
[pkg-q-image]: http://npm.packagequality.com/shield/posthtml-cli.svg?style=flat-square
7273
[npm-total-download-url]: https://www.npmjs.com/package/posthtml-cli
7374
[npm-total-download-image]: https://img.shields.io/npm/dt/posthtml-cli.svg?style=flat-square
7475
[npm-download-url]: https://www.npmjs.com/package/posthtml-cli
@@ -81,9 +82,5 @@ $ posthtml --help
8182
[testen-image]: https://img.shields.io/badge/testen-passing-brightgreen.svg?style=flat-square
8283
[coveralls-url]: https://coveralls.io/r/posthtml/posthtml-cli
8384
[coveralls-image]: http://img.shields.io/coveralls/posthtml/posthtml-cli.svg?style=flat-square
84-
[depstat-url]: https://david-dm.org/posthtml/posthtml-cli
85-
[depstat-image]: https://david-dm.org/posthtml/posthtml-cli.svg?style=flat-square
86-
[depstat-dev-url]: https://david-dm.org/posthtml/posthtml-cli
87-
[depstat-dev-image]: https://david-dm.org/posthtml/posthtml-cli/dev-status.svg?style=flat-square
8885
[style-url]: https://github.com/sindresorhus/xo
89-
[style]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square
86+
[style]: https://badgen.net/xo/status/chalk?style=flat-square

src/cfg-resolve.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default ({input, flags = {}}) => {
1212
options = {},
1313
output,
1414
root = './',
15+
skip = [],
1516
allInOutput = false
1617
} = flags;
1718

@@ -66,6 +67,10 @@ export default ({input, flags = {}}) => {
6667
allInOutput = config.allInOutput;
6768
}
6869

70+
if (config?.skip) {
71+
skip = skip.concat(config.skip);
72+
}
73+
6974
input = []
7075
.concat(input && input.length > 0 ? input : config?.input)
7176
.filter(Boolean)
@@ -90,11 +95,14 @@ export default ({input, flags = {}}) => {
9095
output = normalizePath(output);
9196
}
9297

98+
skip = skip.map(file => normalizePath(path.join(path.resolve(root), file)));
99+
93100
return mergeOptions(config ?? {}, {
94101
input,
95102
output,
96103
options,
97104
root,
98-
allInOutput
105+
allInOutput,
106+
skip
99107
}, use ?? {});
100108
};

src/cli.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ const cli = meow(`
7171
type: 'boolean',
7272
default: false,
7373
alias: 'a'
74+
},
75+
skip: {
76+
type: 'string',
77+
alias: 's',
78+
isMultiple: true
7479
}
7580
}
7681
});
@@ -95,10 +100,15 @@ const config = cfgResolve(cli);
95100
const processing = async file => {
96101
const output = await outResolve(file, config);
97102
const plugins = Array.isArray(config.plugins) ? config.plugins : getPlugins(config);
103+
const skipParse = config.skip.includes(file);
98104

99105
makeDir(path.dirname(output))
100106
.then(read.bind(undefined, file))
101-
.then(html => Promise.resolve(posthtml(plugins).process(html, {...config.options, from: file})))
107+
.then(html => Promise.resolve(posthtml(plugins).process(html, {
108+
...config.options,
109+
skipParse,
110+
from: file
111+
})))
102112
.then(({html}) => {
103113
fs.writeFile(output, html, error => {
104114
if (error) {

test/config/.config-skip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'skip': 'input-skip.html'
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<custome-element>input-skip-skip</custome-element>

test/expected/output-skip/input.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>input-skip-index</div>

0 commit comments

Comments
 (0)