Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CI detection to avoid unwanted TTY behavior (#5804)
- Loading branch information
Showing
11 changed files
with
140 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
"use strict"; | ||
|
||
const getStream = require("get-stream"); | ||
const cosmiconfig = require("cosmiconfig"); | ||
const findParentDir = require("find-parent-dir").sync; | ||
const getStream = require("get-stream"); | ||
const isCIValue = require("is-ci"); | ||
|
||
module.exports = { | ||
getStream, | ||
cosmiconfig, | ||
findParentDir | ||
findParentDir, | ||
getStream, | ||
isCI: /* istanbul ignore next */ () => isCIValue | ||
}; |
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,10 @@ | ||
"use strict"; | ||
|
||
const thirdParty = require("../common/third-party"); | ||
|
||
// Some CI pipelines incorrectly report process.stdout.isTTY status, | ||
// which causes unwanted lines in the output. An additional check for isCI() helps. | ||
// See https://github.com/prettier/prettier/issues/5801 | ||
module.exports = function isTTY() { | ||
return process.stdout.isTTY && !thirdParty.isCI(); | ||
}; |
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 |
---|---|---|
@@ -1,5 +1,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stderr) 1`] = `""`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stderr) 2`] = `""`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stdout) 1`] = ` | ||
"Checking formatting... | ||
unformatted.js | ||
Code style issues found in the above file(s). Forgot to run Prettier? | ||
" | ||
`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stdout) 2`] = ` | ||
"Checking formatting... | ||
unformatted.js | ||
Code style issues found in the above file(s). Forgot to run Prettier? | ||
" | ||
`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (write) 1`] = `Array []`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (write) 2`] = `Array []`; | ||
|
||
exports[`checks stdin with --check (write) 1`] = `Array []`; | ||
|
||
exports[`checks stdin with -c (alias for --check) (write) 1`] = `Array []`; |
18 changes: 18 additions & 0 deletions
18
tests_integration/__tests__/__snapshots__/list-different.js.snap
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 |
---|---|---|
@@ -1,5 +1,23 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`--list-different works in CI just as in a non-TTY mode (stderr) 1`] = `""`; | ||
|
||
exports[`--list-different works in CI just as in a non-TTY mode (stderr) 2`] = `""`; | ||
|
||
exports[`--list-different works in CI just as in a non-TTY mode (stdout) 1`] = ` | ||
"unformatted.js | ||
" | ||
`; | ||
|
||
exports[`--list-different works in CI just as in a non-TTY mode (stdout) 2`] = ` | ||
"unformatted.js | ||
" | ||
`; | ||
|
||
exports[`--list-different works in CI just as in a non-TTY mode (write) 1`] = `Array []`; | ||
|
||
exports[`--list-different works in CI just as in a non-TTY mode (write) 2`] = `Array []`; | ||
|
||
exports[`checks stdin with --list-different (write) 1`] = `Array []`; | ||
|
||
exports[`checks stdin with -l (alias for --list-different) (write) 1`] = `Array []`; |
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