@pixeleye/cli-env
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -1,4 +0,1 @@ | ||
// src/getEnv.ts | ||
import envCi from "env-ci"; | ||
// src/git.ts | ||
@@ -26,16 +23,38 @@ import { $ } from "execa"; | ||
import { logger } from "@pixeleye/cli-logger"; | ||
// src/services/index.ts | ||
import envCi from "env-ci"; | ||
// src/services/github.ts | ||
function getGithubEnv(env) { | ||
return { | ||
...env, | ||
prBranch: process.env.GITHUB_HEAD_REF | ||
}; | ||
} | ||
// src/services/index.ts | ||
function getEnv() { | ||
const env = envCi(); | ||
switch (env.service) { | ||
case "github": | ||
return getGithubEnv(env); | ||
default: | ||
return env; | ||
} | ||
} | ||
// src/getEnv.ts | ||
async function getEnvironment() { | ||
const env = envCi({ | ||
env: process.env, | ||
root: process.cwd() | ||
}); | ||
const env = getEnv(); | ||
logger.debug(`Detected CI: ${JSON.stringify(env)}`); | ||
const { name, isCi, pr, branch, commit, tag, prBranch, isPr } = env; | ||
const { name, isCi, pr, branch: ciBranch, commit, tag, prBranch, isPr } = env; | ||
const gitBranch = await getBranch().catch(() => void 0); | ||
const gitCommit = await getCommit().catch(() => void 0); | ||
const branch = process.env.PIXELEYE_BRANCH || ciBranch || gitBranch; | ||
return { | ||
name, | ||
commit: (process.env.PIXELEYE_COMMIT || commit || gitCommit)?.trim(), | ||
branch: process.env.PIXELEYE_BRANCH || branch || gitBranch, | ||
targetBranch: process.env.PIXELEYE_PR_BRANCH || prBranch, | ||
branch: process.env.PIXELEYE_BASE_BRANCH || isPr ? prBranch : branch, | ||
targetBranch: isPr ? process.env.PIXELEYE_PR_BRANCH || branch : void 0, | ||
isCI: isCi, | ||
@@ -42,0 +61,0 @@ isPR: isPr, |
{ | ||
"name": "@pixeleye/cli-env", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"private": false, | ||
@@ -24,3 +24,3 @@ "license": "AGPL-3.0", | ||
"@pixeleye/tsconfig": "0.0.0", | ||
"@pixeleye/cli-logger": "0.2.5" | ||
"@pixeleye/cli-logger": "0.2.6" | ||
}, | ||
@@ -27,0 +27,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
44265
17
216
15