Skip to content

Commit 4616152

Browse files
authored
Merge pull request #314 from posthtml/milestone-0.7.3
Milestone 0.7.3
2 parents 27d39ba + e6ab03f commit 4616152

13 files changed

Lines changed: 184 additions & 53 deletions

File tree

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"@babel/preset-env",
55
{
66
"targets": {
7-
"node": 8
7+
"node": 10
88
}
99
}
1010
],

changelog.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
1+
## <small>0.7.3 (2020-08-18)</small>
2+
3+
* perf: default for base config ([8d93107](https://github.com/posthtml/posthtml-cli/commit/8d93107))
4+
* perf: tree options from for plugins, #303 ([981e911](https://github.com/posthtml/posthtml-cli/commit/981e911)), closes [#303](https://github.com/posthtml/posthtml-cli/issues/303)
5+
* test: async/await not needed ([3165971](https://github.com/posthtml/posthtml-cli/commit/3165971))
6+
* test: default for base config ([7a96127](https://github.com/posthtml/posthtml-cli/commit/7a96127))
7+
* test: fix input file param, issue #308,#313 ([d76f655](https://github.com/posthtml/posthtml-cli/commit/d76f655)), closes [#308](https://github.com/posthtml/posthtml-cli/issues/308) [#313](https://github.com/posthtml/posthtml-cli/issues/313)
8+
* test: fix not remove expected files/folders ([f744687](https://github.com/posthtml/posthtml-cli/commit/f744687))
9+
* test: fix one/two io ([e72206a](https://github.com/posthtml/posthtml-cli/commit/e72206a))
10+
* test: if input not found ([4360836](https://github.com/posthtml/posthtml-cli/commit/4360836))
11+
* test: input from config, issue #308,#313 ([c8f9a54](https://github.com/posthtml/posthtml-cli/commit/c8f9a54)), closes [#308](https://github.com/posthtml/posthtml-cli/issues/308) [#313](https://github.com/posthtml/posthtml-cli/issues/313)
12+
* test: output resolve from config, issue #308 ([c13d78b](https://github.com/posthtml/posthtml-cli/commit/c13d78b)), closes [#308](https://github.com/posthtml/posthtml-cli/issues/308)
13+
* test: resolve output when CLI priority ([4ad0c33](https://github.com/posthtml/posthtml-cli/commit/4ad0c33))
14+
* fix: input map is not defined ([144a101](https://github.com/posthtml/posthtml-cli/commit/144a101))
15+
* fix: resolve incommitg input, close #313 ([4540719](https://github.com/posthtml/posthtml-cli/commit/4540719)), closes [#313](https://github.com/posthtml/posthtml-cli/issues/313)
16+
* fix: resolve or error inputs file, close #313 ([0b53fa2](https://github.com/posthtml/posthtml-cli/commit/0b53fa2)), closes [#313](https://github.com/posthtml/posthtml-cli/issues/313)
17+
* fix: resolve output from config, close #308 ([8588060](https://github.com/posthtml/posthtml-cli/commit/8588060)), closes [#308](https://github.com/posthtml/posthtml-cli/issues/308)
18+
* build: up node targets for preset env ([3a01485](https://github.com/posthtml/posthtml-cli/commit/3a01485))
19+
20+
21+
122
## <small>0.7.2 (2020-08-17)</small>
223

24+
* 0.7.2 ([81b6217](https://github.com/posthtml/posthtml-cli/commit/81b6217))
325
* build: commit lint incorrect work on v9.1.2, #312 ([255ceb1](https://github.com/posthtml/posthtml-cli/commit/255ceb1)), closes [#312](https://github.com/posthtml/posthtml-cli/issues/312)
26+
* build: update changelog ([83181f7](https://github.com/posthtml/posthtml-cli/commit/83181f7))
427
* build: update dep dev ([44a79b3](https://github.com/posthtml/posthtml-cli/commit/44a79b3))
528
* ci: skip test on window, #308 ([850c93a](https://github.com/posthtml/posthtml-cli/commit/850c93a)), closes [#308](https://github.com/posthtml/posthtml-cli/issues/308)
629
* docs: describe list input file to folder ([e6d06a0](https://github.com/posthtml/posthtml-cli/commit/e6d06a0))

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posthtml-cli",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"description": "CLI for posthtml",
55
"license": "MIT",
66
"repository": "posthtml/posthtml-cli",

src/cfg-resolve.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import mergeOptions from 'merge-options';
55

66
export default ({input, flags = {}}) => {
77
const explorer = cosmiconfigSync('posthtml');
8-
let {config, use, options = {}, output, root = './', allInOutput} = flags;
8+
let {
9+
config,
10+
use,
11+
options = {},
12+
output,
13+
root = './',
14+
allInOutput = false
15+
} = flags;
916

1017
if (config) {
1118
({config} = explorer.load(config));
@@ -19,11 +26,20 @@ export default ({input, flags = {}}) => {
1926
({config} = explorer.search());
2027
}
2128

22-
return mergeOptions(config || {}, {
23-
input: input.map(file => path.join(path.resolve(root), file)),
24-
output,
29+
input = []
30+
.concat(input && input.length > 0 ? input : config?.input)
31+
.filter(Boolean)
32+
.map(file => path.join(path.resolve(root), file));
33+
34+
if (input.length === 0) {
35+
throw new TypeError('input files not found');
36+
}
37+
38+
return mergeOptions(config ?? {}, {
39+
input,
40+
output: output ?? config?.output,
2541
options,
2642
root,
2743
allInOutput
28-
}, use || {});
44+
}, use ?? {});
2945
};

src/cli.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ const cli = meow(`
6161
root: {
6262
type: 'string',
6363
alias: 'r',
64-
default: '.'
64+
default: './'
6565
},
6666
allInOutput: {
6767
type: 'boolean',
68+
default: false,
6869
alias: 'a'
6970
}
7071
}
@@ -93,7 +94,7 @@ const processing = async file => {
9394

9495
makeDir(path.dirname(output))
9596
.then(read.bind(undefined, file))
96-
.then(html => Promise.resolve(posthtml(plugins).process(html, config.options)))
97+
.then(html => Promise.resolve(posthtml(plugins).process(html, {...config.options, from: file})))
9798
.then(({html}) => {
9899
fs.writeFile(output, html, error => {
99100
if (error) {

test/config/.config-input

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'input': 'src/**/*.html'
3+
}

test/config/.config-output

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'output': 'dist/output.html'
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'output': 'dist/output.html'
3+
}
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"input": [
3-
"test/fixtures/by-config/two-io/input-1.html",
4-
"test/fixtures/by-config/two-io/input-2.html"
5-
],
6-
"output": "test/expected/by-config/two-io/",
2+
"input": "test/fixtures/by-config/one-io/input.html",
3+
"output": "test/expected/by-config/one-io/output.html",
74
"plugins": {}
85
}

0 commit comments

Comments
 (0)