smoke - fail early if cloning fails

This commit is contained in:
Benjamin Pasero 2022-05-02 08:38:03 +02:00
parent c6bd448948
commit f90dd46fc3
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65

View file

@ -218,12 +218,15 @@ async function setupRepository(): Promise<void> {
} else {
if (!fs.existsSync(workspacePath)) {
logger.log('Cloning test project repository...');
cp.spawnSync('git', ['clone', testRepoUrl, workspacePath]);
const res = cp.spawnSync('git', ['clone', testRepoUrl, workspacePath], { stdio: 'inherit' });
if (!fs.existsSync(workspacePath)) {
throw new Error(`Clone operation failed: ${res.stderr.toString()}`);
}
} else {
logger.log('Cleaning test project repository...');
cp.spawnSync('git', ['fetch'], { cwd: workspacePath });
cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: workspacePath });
cp.spawnSync('git', ['clean', '-xdf'], { cwd: workspacePath });
cp.spawnSync('git', ['fetch'], { cwd: workspacePath, stdio: 'inherit' });
cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: workspacePath, stdio: 'inherit' });
cp.spawnSync('git', ['clean', '-xdf'], { cwd: workspacePath, stdio: 'inherit' });
}
}
}