-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade repos in set protocol viewers
- Loading branch information
1 parent
34aa7b6
commit 2dcd5ba
Showing
5 changed files
with
86 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//requiring path and fs modules | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
//joining path of directory | ||
const directoryPath = path.join(__dirname, '../artifacts/json'); | ||
|
||
//passsing directoryPath and callback function | ||
fs.readdir(directoryPath, function (err, files) { | ||
//handling error | ||
if (err) { | ||
return console.log('Unable to scan directory: ' + err); | ||
} | ||
//listing all files using forEach | ||
files.forEach(function (file) { | ||
const baseName = file.replace('.json', ''); | ||
const filePath = path.join(__dirname, '../artifacts/json', file); | ||
const newPath = path.join(__dirname, '../artifacts/ts', `${baseName}.ts`); | ||
const contents = fs.readFileSync(filePath, 'utf8'); | ||
let json = JSON.parse(contents); | ||
delete json["ast"] | ||
delete json["legacyAST"] | ||
|
||
fs.writeFileSync(newPath, `export const ${baseName} = `); | ||
fs.appendFileSync(newPath, `${JSON.stringify(json)}`); | ||
console.log(`Finished writing to ${newPath}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters