diff --git a/src/cli/util.js b/src/cli/util.js index 7fb64538..592575c0 100644 --- a/src/cli/util.js +++ b/src/cli/util.js @@ -420,14 +420,7 @@ function eachFilename(context, patterns, callback) { process.exitCode = 2; return; } - filePaths.forEach(filePath => - callback( - filePath, - Object.assign(getOptionsForFile(context, filePath), { - filepath: filePath - }) - ) - ); + filePaths.forEach(filePath => callback(filePath)); } catch (error) { context.logger.error( `Unable to expand glob patterns: ${patterns.join(" ")}\n${error.message}` @@ -448,7 +441,7 @@ function formatFiles(context) { context.logger.log("Checking formatting..."); } - eachFilename(context, context.filePatterns, (filename, options) => { + eachFilename(context, context.filePatterns, filename => { const fileIgnored = ignorer.filter([filename]).length === 0; if ( fileIgnored && @@ -460,6 +453,10 @@ function formatFiles(context) { return; } + const options = Object.assign(getOptionsForFile(context, filename), { + filepath: filename + }); + if (isTTY()) { // Don't use `console.log` here since we need to replace this line. context.logger.log(filename, { newline: false }); diff --git a/tests_integration/cli/ignore-absolute-path/ignored/.prettierrc.js b/tests_integration/cli/ignore-absolute-path/ignored/.prettierrc.js new file mode 100644 index 00000000..efe59c0c --- /dev/null +++ b/tests_integration/cli/ignore-absolute-path/ignored/.prettierrc.js @@ -0,0 +1 @@ +throw Error('This config should not be evaluated since the directory is ignored'); diff --git a/tests_integration/cli/ignore-relative-path/level1/level2/.prettierrc.js b/tests_integration/cli/ignore-relative-path/level1/level2/.prettierrc.js new file mode 100644 index 00000000..efe59c0c --- /dev/null +++ b/tests_integration/cli/ignore-relative-path/level1/level2/.prettierrc.js @@ -0,0 +1 @@ +throw Error('This config should not be evaluated since the directory is ignored');