-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.js
More file actions
25 lines (22 loc) · 734 Bytes
/
utils.js
File metadata and controls
25 lines (22 loc) · 734 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
const { readdirSync } = require('fs')
const { join } = require('path')
const getDeployableFilesFromDir = (dir) => {
const dirCont = readdirSync(dir)
const wasmFileName = dirCont.find(filePath => filePath.match(/.*\.(wasm)$/gi))
const abiFileName = dirCont.find(filePath => filePath.match(/.*\.(abi)$/gi))
if (!wasmFileName) throw new Error(`Cannot find a ".wasm file" in ${dir}`)
if (!abiFileName) throw new Error(`Cannot find an ".abi file" in ${dir}`)
return {
wasmPath: join(dir, wasmFileName),
abiPath: join(dir, abiFileName),
}
}
const wait = async (ms) => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
module.exports = {
wait,
getDeployableFilesFromDir
}