Skip to content

Commit 398d368

Browse files
committed
wip
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent a514e30 commit 398d368

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

tests/integration/setup.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

2020
const { spawnSync } = require('child_process')
21-
const path = require('path');
21+
const path = require('path')
22+
const fs = require('fs');
2223

2324
(function () {
24-
const REQUIRES_NPM_INSTALL = [
25+
const REQUIRES_INSTALL = [
2526
// region functional tests
2627
'webpack5-angular13',
2728
'webpack5-angular17',
@@ -39,6 +40,12 @@ const path = require('path');
3940
pnpm: ['pnpm', ['install', '--frozen-lockfile']]
4041
}
4142

43+
const CleanupMapMethod = {
44+
npm: ['node_modules'],
45+
yarn: ['.yarn'],
46+
pnpm: []
47+
}
48+
4249
console.warn(`
4350
WILL SETUP INTEGRATION TEST BEDS
4451
THAT MIGHT CONTAIN OUTDATED VULNERABLE PACKAGES
@@ -56,11 +63,19 @@ const path = require('path');
5663
`)
5764
}
5865

59-
for (const DIR of REQUIRES_NPM_INSTALL) {
60-
console.log(`>>> setup with ${setupMethod}:`, DIR)
66+
for (const DIR of REQUIRES_INSTALL) {
67+
const testbed = path.resolve(__dirname, DIR)
68+
for (const [cm, cts] of Object.entries(CleanupMapMethod)) {
69+
if (cm === setupMethod) { continue }
70+
console.log(`>>> clean ${cm}: ${DIR}`)
71+
for (const ct in cts) {
72+
fs.rmSync(path.resolve(testbed, ct), { recursive: true, force: true })
73+
}
74+
}
75+
console.log(`>>> setup with ${setupMethod}: ${DIR}`)
6176
const done = spawnSync(
62-
...setupMethodCmdArgs, {
63-
cwd: path.resolve(__dirname, DIR),
77+
setupMethodCmdArgs[0], setupMethodCmdArgs[1], {
78+
cwd: testbed,
6479
stdio: 'inherit',
6580
shell: true
6681
}

0 commit comments

Comments
 (0)