-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixturize.js
58 lines (46 loc) · 1.64 KB
/
fixturize.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const fs = require('fs');
const path = require('path');
const os = require('os');
const process = require('process');
// Replace ~ with the actual home directory
const homeDirectory = os.homedir();
// Define source and destination paths
const sources = [
'./TonkTower',
'./Depots/MemeGenerator',
'./Depots/HexDump',
'./Depots/SelfiePoint'
];
const destination = path.join(homeDirectory, 'Workspace/ds/contracts/src/fixtures/debug-us/');
async function copyFile(sourcePath, destPath) {
return new Promise((resolve, reject) => {
const readStream = fs.createReadStream(sourcePath);
const writeStream = fs.createWriteStream(destPath);
readStream.on('error', reject);
writeStream.on('error', reject);
writeStream.on('finish', resolve);
readStream.pipe(writeStream);
});
}
async function copyFilesFromDirectory(sourceDir) {
const files = fs.readdirSync(sourceDir);
for (const file of files) {
const sourceFilePath = path.join(sourceDir, file);
let destFilePath = path.join(destination, file);
if (file === 'manifest.yaml') {
const parentDirName = path.basename(sourceDir);
destFilePath = path.join(destination, `${parentDirName}.yaml`);
}
await copyFile(sourceFilePath, destFilePath);
}
}
async function main() {
for (const source of sources) {
await copyFilesFromDirectory(source);
}
await copyFile(path.join(process.cwd(),'map.yaml'), path.join(destination, 'map.yaml'));
console.log("Files copied successfully!");
}
main().catch(error => {
console.error("An error occurred:", error);
});