Skip to content

Commit f0e720e

Browse files
committed
feat: Add path option to specify validation target
1 parent 41976d0 commit f0e720e

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The following parameters can be used for `plugin.inputs`
2727
|-----------|------------------------------------------------------------------------------------------------------------------------------|----------|---------|
2828
| `ext` | The file-name extension that identifies HTML files | no | `html` |
2929
| `config` | Configuration for `html-validate`; e.g. `.htmlvalidate.json`. If left blank, `html-validate`'s default options will be used. | no | |
30+
| `path` | Source to validate; provide a file name, directory or glob pattern. | no | |
3031

3132
### Configure validation rules for `html-validate`
3233

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
[
77
...inputs.config ? ['--config', inputs.config] : [],
88
'--ext', inputs.ext,
9-
constants.PUBLISH_DIR,
9+
inputs.path || constants.PUBLISH_DIR,
1010
],
1111
);
1212
} catch (error) {

index.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ tap.test('overwrites config path', async (t) => {
3131
t.sameStrict(actual, expected, 'Function called with incorrect parameters');
3232
});
3333

34+
tap.test('overwrites source path', async (t) => {
35+
const run = sinon.fake();
36+
await onPostBuild({
37+
inputs: { ext: 'html', path: 'dist' },
38+
constants: { PUBLISH_DIR: '_site' },
39+
utils: { run },
40+
});
41+
42+
const expected = ['html-validate', ['--ext', 'html', 'dist']];
43+
const actual = run.getCall(0).args;
44+
45+
t.sameStrict(actual, expected, 'Function called with incorrect parameters');
46+
});
47+
3448
tap.test('catches validation error', async (t) => {
3549
const error = new Error('Something is wrong');
3650
error.exitCode = 1;

manifest.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ inputs:
55
description: The file-name extension that identifies HTML files; default 'html'
66
- name: config
77
description: Configuration for html-validate
8+
- name: path
9+
description: Source to validate; provide a file name, directory or glob pattern.

0 commit comments

Comments
 (0)