-
-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow a path to be supplied to the --shell option (#994)
- Loading branch information
Showing
10 changed files
with
301 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { promises: fs, constants } = require('fs') | ||
|
||
const { invalidOption } = require('./messages') | ||
const { InvalidOptionsError } = require('./symbols') | ||
|
||
const debug = require('debug')('lint-staged:options') | ||
|
||
/** | ||
* Validate lint-staged options, either from the Node.js API or the command line flags. | ||
* @param {*} options | ||
* @param {boolean|string} [options.shell] - Skip parsing of tasks for better shell support | ||
* | ||
* @throws {InvalidOptionsError} | ||
*/ | ||
const validateOptions = async (options = {}, logger) => { | ||
debug('Validating options...') | ||
|
||
/** Ensure the passed shell option is executable */ | ||
if (typeof options.shell === 'string') { | ||
try { | ||
await fs.access(options.shell, constants.X_OK) | ||
} catch (error) { | ||
logger.error(invalidOption('shell', options.shell, error.message)) | ||
throw InvalidOptionsError | ||
} | ||
} | ||
|
||
debug('Validated options!') | ||
} | ||
|
||
module.exports = validateOptions |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.