forked from trusttoken/contracts-pre22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexBuild.sh
40 lines (31 loc) · 965 Bytes
/
indexBuild.sh
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
#!/bin/bash
set -e
ODline=$(grep 'outputDirectory' .waffle.json)
regex=': \"(.+)\"'
[[ $ODline =~ $regex ]]
outputDir=${BASH_REMATCH[1]}
touch $outputDir/index.ts
> $outputDir/index.ts
for file in $outputDir/*.json
do
ODline=$(grep 'outputDirectory' .waffle.json)
regex='\/([a-zA-Z0-9_]+)\.'
[[ $file =~ $regex ]]
name=${BASH_REMATCH[1]}
echo "const ${name}Json = require(\"./$name.json\")" >> $outputDir/index.ts
done
echo "export {" >> $outputDir/index.ts
for file in $outputDir/*.json
do
ODline=$(grep 'outputDirectory' .waffle.json)
regex='\/([a-zA-Z0-9_]+)\.'
[[ $file =~ $regex ]]
name=${BASH_REMATCH[1]}
echo " ${name}Json," >> $outputDir/index.ts
done
echo "}" >> $outputDir/index.ts
echo "export * from './types'" >> $outputDir/index.ts
if [[ -z "$(git status --porcelain)" ]]; then
echo "Build canary stored in ${outputDir}/canary.hash"
git log --pretty=format:'%H' -n 1 > $outputDir/canary.hash
fi