From e7edb75f8357090714213f252c5aaaa9b3c29f5f Mon Sep 17 00:00:00 2001 From: mrazauskas <72159681+mrazauskas@users.noreply.github.com> Date: Mon, 18 Oct 2021 13:55:14 +0300 Subject: [PATCH] chore: remove `is-ci` in favor of `ci-info` (#11973) --- CHANGELOG.md | 2 ++ packages/jest-config/package.json | 3 +- packages/jest-config/src/Defaults.ts | 2 +- packages/jest-util/package.json | 3 +- .../src/__tests__/isInteractive.test.ts | 16 +++++------ packages/jest-util/src/isInteractive.ts | 2 +- yarn.lock | 28 ++----------------- 7 files changed, 17 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb900f8d9b6..08c99d3dc8fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Chore & Maintenance +- `[jest-config, jest-util]` Use `ci-info` instead of `is-ci` to detect CI environment ([11973](https://github.com/facebook/jest/pull/11973)) + ### Performance ## 27.3.0 diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index c404a1c21bf1..3b9c415e4300 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -27,10 +27,10 @@ "@jest/types": "^27.2.5", "babel-jest": "^27.3.0", "chalk": "^4.0.0", + "ci-info": "^3.2.0", "deepmerge": "^4.2.2", "glob": "^7.1.1", "graceful-fs": "^4.2.4", - "is-ci": "^3.0.0", "jest-circus": "^27.3.0", "jest-environment-jsdom": "^27.3.0", "jest-environment-node": "^27.3.0", @@ -48,7 +48,6 @@ "@types/babel__core": "^7.0.4", "@types/glob": "^7.1.1", "@types/graceful-fs": "^4.1.3", - "@types/is-ci": "^3.0.0", "@types/micromatch": "^4.0.1", "jest-snapshot-serializer-raw": "^1.1.0", "semver": "^7.3.5", diff --git a/packages/jest-config/src/Defaults.ts b/packages/jest-config/src/Defaults.ts index d8a31dc02df3..5ccc8e0e4fd4 100644 --- a/packages/jest-config/src/Defaults.ts +++ b/packages/jest-config/src/Defaults.ts @@ -6,7 +6,7 @@ */ import {sep} from 'path'; -import isCI = require('is-ci'); +import {isCI} from 'ci-info'; import type {Config} from '@jest/types'; import {replacePathSepForRegex} from 'jest-regex-util'; import {NODE_MODULES} from './constants'; diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 92040d999911..a6738ab74f9d 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -17,13 +17,12 @@ "@jest/types": "^27.2.5", "@types/node": "*", "chalk": "^4.0.0", + "ci-info": "^3.2.0", "graceful-fs": "^4.2.4", - "is-ci": "^3.0.0", "picomatch": "^2.2.3" }, "devDependencies": { "@types/graceful-fs": "^4.1.2", - "@types/is-ci": "^3.0.0", "@types/micromatch": "^4.0.1", "@types/picomatch": "^2.2.2" }, diff --git a/packages/jest-util/src/__tests__/isInteractive.test.ts b/packages/jest-util/src/__tests__/isInteractive.test.ts index a86c4e9575c9..ae3dd4e82276 100644 --- a/packages/jest-util/src/__tests__/isInteractive.test.ts +++ b/packages/jest-util/src/__tests__/isInteractive.test.ts @@ -20,7 +20,7 @@ afterEach(() => { }); it('Returns true when running on interactive environment', () => { - jest.doMock('is-ci', () => false); + jest.doMock('ci-info', () => ({isCI: false})); process.stdout.isTTY = true; process.env.TERM = 'xterm-256color'; @@ -32,24 +32,24 @@ it('Returns false when running on a non-interactive environment', () => { let isInteractive; const expectedResult = false; - // Test with is-ci being true and isTTY false - jest.doMock('is-ci', () => true); + // Test with isCI being true and isTTY false + jest.doMock('ci-info', () => ({isCI: true})); process.stdout.isTTY = undefined; process.env.TERM = 'xterm-256color'; isInteractive = require('../isInteractive').default; expect(isInteractive).toBe(expectedResult); - // Test with is-ci being false and isTTY false + // Test with isCI being false and isTTY false jest.resetModules(); - jest.doMock('is-ci', () => false); + jest.doMock('ci-info', () => ({isCI: false})); process.stdout.isTTY = undefined; process.env.TERM = 'xterm-256color'; isInteractive = require('../isInteractive').default; expect(isInteractive).toBe(expectedResult); - // Test with is-ci being true and isTTY true + // Test with isCI being true and isTTY true jest.resetModules(); - jest.doMock('is-ci', () => true); + jest.doMock('ci-info', () => ({isCI: true})); process.stdout.isTTY = true; process.env.TERM = 'xterm-256color'; isInteractive = require('../isInteractive').default; @@ -57,7 +57,7 @@ it('Returns false when running on a non-interactive environment', () => { // Test with dumb terminal jest.resetModules(); - jest.doMock('is-ci', () => false); + jest.doMock('ci-info', () => ({isCI: false})); process.stdout.isTTY = undefined; process.env.TERM = 'dumb'; isInteractive = require('../isInteractive').default; diff --git a/packages/jest-util/src/isInteractive.ts b/packages/jest-util/src/isInteractive.ts index e620adadf4df..97c5d1e9a97e 100644 --- a/packages/jest-util/src/isInteractive.ts +++ b/packages/jest-util/src/isInteractive.ts @@ -5,6 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import isCI = require('is-ci'); +import {isCI} from 'ci-info'; export default !!process.stdout.isTTY && process.env.TERM !== 'dumb' && !isCI; diff --git a/yarn.lock b/yarn.lock index 9334d2408d5f..b5e0704bb0f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4552,15 +4552,6 @@ __metadata: languageName: node linkType: hard -"@types/is-ci@npm:^3.0.0": - version: 3.0.0 - resolution: "@types/is-ci@npm:3.0.0" - dependencies: - ci-info: ^3.1.0 - checksum: 661e9cc9ba61e1c283f3814fbb1355aca70b281b5d71def665348f8e17db1fbdf5e62db496b0c2ab7b913e49ad626faa28478c06b9fecf70f860f4386469973f - languageName: node - linkType: hard - "@types/istanbul-lib-coverage@npm:*, @types/istanbul-lib-coverage@npm:^2.0.0, @types/istanbul-lib-coverage@npm:^2.0.1": version: 2.0.3 resolution: "@types/istanbul-lib-coverage@npm:2.0.3" @@ -7089,7 +7080,7 @@ __metadata: languageName: node linkType: hard -"ci-info@npm:^3.0.0, ci-info@npm:^3.1.0, ci-info@npm:^3.1.1": +"ci-info@npm:^3.0.0, ci-info@npm:^3.2.0": version: 3.2.0 resolution: "ci-info@npm:3.2.0" checksum: d4a898d60111d00f2b7a06a349162971fe0603aefa208fe8d1343ce9e93c48e3d37311c47211d5c9040d25b43038c817588e5b7d8eab5d17b00aec49c7b5fade @@ -11989,17 +11980,6 @@ fsevents@^1.2.7: languageName: node linkType: hard -"is-ci@npm:^3.0.0": - version: 3.0.0 - resolution: "is-ci@npm:3.0.0" - dependencies: - ci-info: ^3.1.1 - bin: - is-ci: bin.js - checksum: 1e26d3ba6634ebee83f9d22f260354c5d950eada4d609c30cc2642069f8ba52f3aeb4c9bbf8099aaf04a2f44a1ed7beef2a24485f988753c8c078a57e9b3a2fd - languageName: node - linkType: hard - "is-core-module@npm:^2.2.0, is-core-module@npm:^2.5.0, is-core-module@npm:^2.6.0": version: 2.7.0 resolution: "is-core-module@npm:2.7.0" @@ -12657,14 +12637,13 @@ fsevents@^1.2.7: "@types/babel__core": ^7.0.4 "@types/glob": ^7.1.1 "@types/graceful-fs": ^4.1.3 - "@types/is-ci": ^3.0.0 "@types/micromatch": ^4.0.1 babel-jest: ^27.3.0 chalk: ^4.0.0 + ci-info: ^3.2.0 deepmerge: ^4.2.2 glob: ^7.1.1 graceful-fs: ^4.2.4 - is-ci: ^3.0.0 jest-circus: ^27.3.0 jest-environment-jsdom: ^27.3.0 jest-environment-node: ^27.3.0 @@ -13199,13 +13178,12 @@ fsevents@^1.2.7: dependencies: "@jest/types": ^27.2.5 "@types/graceful-fs": ^4.1.2 - "@types/is-ci": ^3.0.0 "@types/micromatch": ^4.0.1 "@types/node": "*" "@types/picomatch": ^2.2.2 chalk: ^4.0.0 + ci-info: ^3.2.0 graceful-fs: ^4.2.4 - is-ci: ^3.0.0 picomatch: ^2.2.3 languageName: unknown linkType: soft