Skip to content

Commit a77c7a1

Browse files
committed
feat: skip parse option, close #332
1 parent a1188b2 commit a77c7a1

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

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) {

0 commit comments

Comments
 (0)