Skip to content

Commit

Permalink
Merge pull request #18 from oclif/mdonnalley/debug
Browse files Browse the repository at this point in the history
fix: use CI mode if DEBUG is set
  • Loading branch information
iowillhoit authored Sep 11, 2024
2 parents 23a0ca2 + cda2e02 commit eb8b1dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@oclif/multi-stage-output",
"description": "Terminal output for oclif commands with multiple stages",
"version": "0.5.3",
"version": "0.5.4-qa.0",
"author": "Salesforce",
"bugs": "https://github.com/oclif/multi-stage-output/issues",
"dependencies": {
Expand Down
33 changes: 28 additions & 5 deletions src/multi-stage-output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,34 @@ import {Design, RequiredDesign, constructDesignParams} from './design.js'
import {StageStatus, StageTracker} from './stage-tracker.js'
import {readableTime} from './utils.js'

// Taken from https://github.com/sindresorhus/is-in-ci
const isInCi =
env.CI !== '0' &&
env.CI !== 'false' &&
('CI' in env || 'CONTINUOUS_INTEGRATION' in env || Object.keys(env).some((key) => key.startsWith('CI_')))
function isTruthy(value: string | undefined): boolean {
return value !== '0' && value !== 'false'
}

/**
* Determines whether the CI mode should be used.
*
* If the MSO_DISABLE_CI_MODE environment variable is set to a truthy value, CI mode will be disabled.
*
* If the CI environment variable is set, CI mode will be enabled.
*
* If the DEBUG environment variable is set, CI mode will be enabled.
*
* @returns {boolean} True if CI mode should be used, false otherwise.
*/
function shouldUseCIMode(): boolean {
if (env.MSO_DISABLE_CI_MODE && isTruthy(env.MSO_DISABLE_CI_MODE)) return false
// Inspired by https://github.com/sindresorhus/is-in-ci
if (
isTruthy(env.CI) &&
('CI' in env || 'CONTINUOUS_INTEGRATION' in env || Object.keys(env).some((key) => key.startsWith('CI_')))
)
return true
if (env.DEBUG && isTruthy(env.DEBUG)) return true
return false
}

const isInCi = shouldUseCIMode()

export type MultiStageOutputOptions<T extends Record<string, unknown>> = {
/**
Expand Down

0 comments on commit eb8b1dd

Please sign in to comment.