1 | import { constants, promises as fs } from 'fs'
|
2 |
|
3 | import debug from 'debug'
|
4 |
|
5 | import { invalidOption } from './messages.js'
|
6 | import { InvalidOptionsError } from './symbols.js'
|
7 |
|
8 | const debugLog = debug('lint-staged:validateOptions')
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export const validateOptions = async (options = {}, logger) => {
|
18 | debugLog('Validating options...')
|
19 |
|
20 |
|
21 | if (typeof options.shell === 'string') {
|
22 | try {
|
23 | await fs.access(options.shell, constants.X_OK)
|
24 | } catch (error) {
|
25 | logger.error(invalidOption('shell', options.shell, error.message))
|
26 | throw InvalidOptionsError
|
27 | }
|
28 | }
|
29 |
|
30 | debugLog('Validated options!')
|
31 | }
|