| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b2fbba1 commit cee19ae
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,27 @@ | |||
| 1 | 1 | /* eslint-env node */ | |
| 2 | 2 | ||
| 3 | 3 | require('dotenv').config({ path: '.env.production' }) | |
| 4 | - | ||
| 5 | - const { exec } = require('child_process') | ||
| 4 | + const child_process = require('child_process') | ||
| 5 | + const fs = require('fs/promises') | ||
| 6 | + const { promisify } = require('util') | ||
| 6 | 7 | const dataConfig = require('../graphql.config') | |
| 7 | 8 | const thegraphConfig = require('../graphql_thegraph.config') | |
| 8 | 9 | ||
| 10 | + const exec = promisify(child_process.exec) | ||
| 11 | + | ||
| 9 | 12 | function fetchSchema(url, outputFile) { | |
| 10 | - exec( | ||
| 11 | - `get-graphql-schema --h Origin=https://app.uniswap.org ${url} | tee ${outputFile}.temp`, | ||
| 12 | - (error, stdout, stderr) => { | ||
| 13 | - if (error || stderr) { | ||
| 14 | - console.log(`Failed to fetch schema from ${url}`) | ||
| 15 | - } else if (stdout) { | ||
| 16 | - exec(`mv ${outputFile}.temp ${outputFile}`) | ||
| 13 | + exec(`npx get-graphql-schema --h Origin=https://app.uniswap.org ${url}`) | ||
| 14 | + .then(({ stderr, stdout }) => { | ||
| 15 | + if (stderr) { | ||
| 16 | + throw new Error(stderr) | ||
| 17 | + } else { | ||
| 18 | + fs.writeFile(outputFile, stdout) | ||
| 17 | 19 | } | |
| 18 | - } | ||
| 19 | - ) | ||
| 20 | + }) | ||
| 21 | + .catch((err) => { | ||
| 22 | + console.error(err) | ||
| 23 | + console.error(`Failed to fetch schema from ${url}`) | ||
| 24 | + }) | ||
| 20 | 25 | } | |
| 21 | 26 | ||
| 22 | 27 | fetchSchema(process.env.THE_GRAPH_SCHEMA_ENDPOINT, thegraphConfig.schema) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments