forked from auxo-zk/Distributed-key-generation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.js
32 lines (26 loc) · 892 Bytes
/
temp.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
const fs = require('fs');
const path = require('path');
// Replace with your actual directory path
const directoryPath = './caches';
// Function to check if 'pk' is not in the file name
const is_valid_file = (fileName) => !(fileName.includes('pk') || fileName.includes('header'));
// Read all files from the directory and filter based on the condition
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Error reading the directory:', err);
return;
}
const validFiles = files.filter(
(file) =>
is_valid_file(file) &&
fs.statSync(path.join(directoryPath, file)).isFile()
);
// Generating the output
let output = 'const cacheContractFile = [\n';
output += validFiles
.map((fileName) => ` { name: '${fileName}', type: 'string' }`)
.join(',\n');
output += '\n];';
// Print the generated code
console.log(output);
});