-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-test-data.js
More file actions
32 lines (24 loc) · 945 Bytes
/
setup-test-data.js
File metadata and controls
32 lines (24 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require('fs');
const path = require('path');
const root = path.join(__dirname, 'test-playground');
if (fs.existsSync(root)) {
fs.rmSync(root, { recursive: true, force: true });
}
fs.mkdirSync(root);
// Create some dummy projects
const projects = ['proj-a', 'proj-b', 'proj-c/nested'];
projects.forEach(p => {
const dir = path.join(root, p);
fs.mkdirSync(dir, { recursive: true });
const nm = path.join(dir, 'node_modules');
fs.mkdirSync(nm);
// Add some dummy files to give it size
fs.writeFileSync(path.join(nm, 'package.json'), '{}');
fs.writeFileSync(path.join(nm, 'readme.md'), '# Dummy'.repeat(100));
// Nested package
const subPkg = path.join(nm, 'lodash');
fs.mkdirSync(subPkg);
fs.writeFileSync(path.join(subPkg, 'index.js'), 'module.exports = {};');
});
console.log(`Created test playground at ${root}`);
console.log('You can select this directory in the app to test scanning and deletion.');