mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
feat(preflight): Use venv for yamllint installation (#11694)
This commit is contained in:
@@ -49,6 +49,13 @@ function getPlatformArch() {
|
||||
|
||||
const platformArch = getPlatformArch();
|
||||
|
||||
const PYTHON_VENV_PATH = join(TEMP_DIR, 'python_venv');
|
||||
|
||||
const yamllintCheck =
|
||||
process.platform === 'win32'
|
||||
? `if exist "${PYTHON_VENV_PATH}\\Scripts\\yamllint.exe" (exit 0) else (exit 1)`
|
||||
: `test -x "${PYTHON_VENV_PATH}/bin/yamllint"`;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* check: string;
|
||||
@@ -97,8 +104,11 @@ const LINTERS = {
|
||||
`,
|
||||
},
|
||||
yamllint: {
|
||||
check: 'command -v yamllint',
|
||||
installer: `pip3 install --user "yamllint==${YAMLLINT_VERSION}"`,
|
||||
check: yamllintCheck,
|
||||
installer: `
|
||||
python3 -m venv "${PYTHON_VENV_PATH}" && \
|
||||
"${PYTHON_VENV_PATH}/bin/pip" install "yamllint==${YAMLLINT_VERSION}"
|
||||
`,
|
||||
run: "git ls-files | grep -E '\\.(yaml|yml)' | xargs yamllint --format github",
|
||||
},
|
||||
};
|
||||
@@ -107,12 +117,7 @@ function runCommand(command, stdio = 'inherit') {
|
||||
try {
|
||||
const env = { ...process.env };
|
||||
const nodeBin = join(process.cwd(), 'node_modules', '.bin');
|
||||
env.PATH = `${nodeBin}:${TEMP_DIR}/actionlint:${TEMP_DIR}/shellcheck:${env.PATH}`;
|
||||
if (process.platform === 'darwin') {
|
||||
env.PATH = `${env.PATH}:${process.env.HOME}/Library/Python/3.12/bin`;
|
||||
} else if (process.platform === 'linux') {
|
||||
env.PATH = `${env.PATH}:${process.env.HOME}/.local/bin`;
|
||||
}
|
||||
env.PATH = `${nodeBin}:${TEMP_DIR}/actionlint:${TEMP_DIR}/shellcheck:${PYTHON_VENV_PATH}/bin:${env.PATH}`;
|
||||
execSync(command, { stdio, env });
|
||||
return true;
|
||||
} catch (_e) {
|
||||
|
||||
Reference in New Issue
Block a user