From a3bd9d7fa0b85983eb25f8483b407a14b15c1f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Fri, 24 Apr 2020 14:02:49 +0300 Subject: [PATCH] feat: allow specifying `cwd` using the Node.js API --- README.md | 2 ++ lib/index.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index d30042762..195c08006 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,7 @@ const success = await lintStaged({ allowEmpty: false, concurrent: true, configPath: './path/to/configuration/file', + cwd: process.cwd(), debug: false, maxArgLength: null, quiet: false, @@ -445,6 +446,7 @@ const success = await lintStaged({ allowEmpty: false, concurrent: true, config: { '*.js': 'eslint --fix' }, + cwd: process.cwd(), debug: false, maxArgLength: null, quiet: false, diff --git a/lib/index.js b/lib/index.js index 1a3a67f3f..e9423e45d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -48,6 +48,7 @@ function loadConfig(configPath) { * @param {boolean | number} [options.concurrent] - The number of tasks to run concurrently, or false to run tasks serially * @param {object} [options.config] - Object with configuration for programmatic API * @param {string} [options.configPath] - Path to configuration file + * @param {Object} [options.cwd] - Current working directory * @param {boolean} [options.debug] - Enable debug mode * @param {number} [options.maxArgLength] - Maximum argument string length * @param {boolean} [options.quiet] - Disable lint-staged’s own console output @@ -65,6 +66,7 @@ module.exports = async function lintStaged( concurrent = true, config: configObject, configPath, + cwd = process.cwd(), debug = false, maxArgLength, quiet = false, @@ -107,6 +109,7 @@ module.exports = async function lintStaged( allowEmpty, concurrent, config, + cwd, debug, maxArgLength, quiet,