Skip to content

Commit a3bd9d7

Browse files
committed
feat: allow specifying cwd using the Node.js API
1 parent 85de3a3 commit a3bd9d7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ const success = await lintStaged({
428428
allowEmpty: false,
429429
concurrent: true,
430430
configPath: './path/to/configuration/file',
431+
cwd: process.cwd(),
431432
debug: false,
432433
maxArgLength: null,
433434
quiet: false,
@@ -445,6 +446,7 @@ const success = await lintStaged({
445446
allowEmpty: false,
446447
concurrent: true,
447448
config: { '*.js': 'eslint --fix' },
449+
cwd: process.cwd(),
448450
debug: false,
449451
maxArgLength: null,
450452
quiet: false,

lib/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function loadConfig(configPath) {
4848
* @param {boolean | number} [options.concurrent] - The number of tasks to run concurrently, or false to run tasks serially
4949
* @param {object} [options.config] - Object with configuration for programmatic API
5050
* @param {string} [options.configPath] - Path to configuration file
51+
* @param {Object} [options.cwd] - Current working directory
5152
* @param {boolean} [options.debug] - Enable debug mode
5253
* @param {number} [options.maxArgLength] - Maximum argument string length
5354
* @param {boolean} [options.quiet] - Disable lint-staged’s own console output
@@ -65,6 +66,7 @@ module.exports = async function lintStaged(
6566
concurrent = true,
6667
config: configObject,
6768
configPath,
69+
cwd = process.cwd(),
6870
debug = false,
6971
maxArgLength,
7072
quiet = false,
@@ -107,6 +109,7 @@ module.exports = async function lintStaged(
107109
allowEmpty,
108110
concurrent,
109111
config,
112+
cwd,
110113
debug,
111114
maxArgLength,
112115
quiet,

0 commit comments

Comments
 (0)