@@ -19,6 +19,7 @@ import { languageKeys } from '../lib/languages.js'
19
19
import warmServer from '../lib/warm-server.js'
20
20
import renderContent from '../lib/render-content/index.js'
21
21
import { deprecated } from '../lib/enterprise-server-releases.js'
22
+ import readFileAsync from '../lib/readfile-async.js'
22
23
23
24
const STATIC_PREFIXES = {
24
25
assets : path . resolve ( 'assets' ) ,
@@ -65,13 +66,33 @@ program
65
66
}
66
67
return parsed
67
68
} )
69
+ . option (
70
+ '--list <file>.json' ,
71
+ 'JSON file containing an array of specific files to check (default: none)' ,
72
+ ( filePath ) => {
73
+ const resolvedPath = path . resolve ( filePath )
74
+
75
+ let stats
76
+ try {
77
+ stats = fs . statSync ( resolvedPath )
78
+ } catch ( error ) {
79
+ // Ignore
80
+ }
81
+
82
+ if ( ! stats || ! stats . isFile ( ) ) {
83
+ throw new InvalidArgumentError ( 'Not an existing file.' )
84
+ }
85
+
86
+ return resolvedPath
87
+ }
88
+ )
68
89
. arguments ( '[files...]' , 'Specific files to check' )
69
90
. parse ( process . argv )
70
91
71
92
main ( program . opts ( ) , program . args )
72
93
73
94
async function main ( opts , files ) {
74
- const { random, language, filter, exit, debug, max, verbose } = opts
95
+ const { random, language, filter, exit, debug, max, verbose, list } = opts
75
96
76
97
// Note! The reason we're using `warmServer()` in this script,
77
98
// even though there's no server involved, is because
@@ -89,6 +110,19 @@ async function main(opts, files) {
89
110
const filters = filter || [ ]
90
111
console . assert ( Array . isArray ( filters ) , `${ filters } is not an array` )
91
112
113
+ if ( list && Array . isArray ( files ) && files . length > 0 ) {
114
+ throw new InvalidArgumentError ( 'Cannot specify both --list and a file list.' )
115
+ }
116
+
117
+ if ( list ) {
118
+ const fileList = JSON . parse ( await readFileAsync ( list ) )
119
+ if ( Array . isArray ( fileList ) && fileList . length > 0 ) {
120
+ files = fileList
121
+ } else {
122
+ throw new InvalidArgumentError ( 'No files found in --list.' )
123
+ }
124
+ }
125
+
92
126
if ( random ) {
93
127
shuffle ( pageList )
94
128
}
0 commit comments