Don't fail tests if Git is not available

I need this because I run Node inside a
minimal container for security reasons.
This commit is contained in:
Jakob Linskeseder
2026-03-18 19:51:15 +01:00
committed by Jay Linski
parent bf93bafeca
commit 71350d90ec
+3 -1
View File
@@ -1,6 +1,7 @@
const os = require('os'); const os = require('os');
const path = require('path'); const path = require('path');
const fs = require('fs-extra'); const fs = require('fs-extra');
const { spawnSync } = require('child_process');
const git = require('../util/git'); const git = require('../util/git');
@@ -9,8 +10,9 @@ const tmpDir = path.join(tmpBaseDir, Date.now().toString(36));
const remoteDir = path.join(tmpDir, 'remote-repo'); const remoteDir = path.join(tmpDir, 'remote-repo');
const cloneDir = path.join(tmpDir, 'clone-repo'); const cloneDir = path.join(tmpDir, 'clone-repo');
const oldCwd = process.cwd(); const oldCwd = process.cwd();
const gitInstalled = spawnSync('git', ['-v'], { stdio: 'ignore' }).status === 0;
describe('utils/git', function () { describe.runIf(gitInstalled)('utils/git', function () {
beforeEach(async function () { beforeEach(async function () {
await fs.remove(tmpDir); await fs.remove(tmpDir);
await createRepositoryThatActsAsRemote(); await createRepositoryThatActsAsRemote();