Skip to content

Commit c2a99dd

Browse files
committed
fix(index.js): after lint xo
1 parent 43d9f3c commit c2a99dd

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

lib/index.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22

33
const fs = require('fs');
44
const path = require('path');
5-
const process = require('process');
65
const posthtml = require('posthtml');
76
const {parser} = require('posthtml-parser');
87
const {match} = require('posthtml/lib/api');
98
const expressions = require('posthtml-expressions');
109

1110
module.exports = (options = {}) => {
12-
options.root = options.root
13-
? path.resolve(options.root)
14-
: process.cwd();
11+
options.root = options.root ?
12+
path.resolve(options.root) :
13+
process.cwd();
1514
options.encoding = options.encoding || 'utf-8';
1615

1716
return function posthtmlInclude(tree) {
18-
const cwd = options.cwd
19-
? path.resolve(options.cwd)
20-
: tree.options.from
21-
? path.dirname(path.resolve(tree.options.from))
22-
: process.cwd()
17+
const cwd = options.cwd ?
18+
path.resolve(options.cwd) :
19+
(tree.options.from ?
20+
path.dirname(path.resolve(tree.options.from)) :
21+
process.cwd())
2322

2423
tree.parser = tree.parser || parser;
2524
tree.match = tree.match || match;
@@ -35,9 +34,9 @@ module.exports = (options = {}) => {
3534
}
3635

3736
if (src) {
38-
src = path.isAbsolute(src)
39-
? path.join(options.root, src)
40-
: path.resolve(cwd, src)
37+
src = path.isAbsolute(src) ?
38+
path.join(options.root, src) :
39+
path.resolve(cwd, src)
4140
source = fs.readFileSync(src, options.encoding);
4241

4342
try {
@@ -58,11 +57,11 @@ module.exports = (options = {}) => {
5857

5958
subtree = tree.parser(source);
6059
subtree.options = subtree.options || {};
61-
subtree.options.from = path.isAbsolute(src)
62-
? src
63-
: tree.options.from
64-
? path.relative(tree.options.from, src)
65-
: src;
60+
subtree.options.from = path.isAbsolute(src) ?
61+
src :
62+
(tree.options.from ?
63+
path.relative(tree.options.from, src) :
64+
src);
6665
subtree.match = tree.match;
6766
subtree.parser = tree.parser;
6867
subtree.messages = tree.messages;

0 commit comments

Comments
 (0)