Skip to content

Commit

Permalink
chore: extract isInEditorEnv function (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunsii authored Jul 20, 2024
1 parent dd2ad98 commit ba54978
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import process from 'node:process'
import { isPackageExists } from 'local-pkg'
import { FlatConfigComposer } from 'eslint-flat-config-utils'
import type { Linter } from 'eslint'
Expand Down Expand Up @@ -30,7 +29,7 @@ import {
vue,
yaml,
} from './configs'
import { interopDefault } from './utils'
import { interopDefault, isInEditorEnv } from './utils'
import { formatters } from './configs/formatters'
import { regexp } from './configs/regexp'
import type { RuleOptions } from './typegen'
Expand Down Expand Up @@ -87,7 +86,7 @@ export function antfu(
autoRenamePlugins = true,
componentExts = [],
gitignore: enableGitignore = true,
isInEditor = !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI),
isInEditor = isInEditorEnv(),
jsx: enableJsx = true,
react: enableReact = false,
regexp: enableRegexp = true,
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,7 @@ export async function ensurePackages(packages: (string | undefined)[]): Promise<
if (result)
await import('@antfu/install-pkg').then(i => i.installPackage(nonExistingPackages, { dev: true }))
}

export function isInEditorEnv(): boolean {
return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI)
}

0 comments on commit ba54978

Please sign in to comment.