From 291ba25f724107b8ff7e0b78bf9c3050ecc43fba Mon Sep 17 00:00:00 2001 From: stringcoode Date: Fri, 18 Oct 2024 16:57:15 +0300 Subject: [PATCH] Adding check for __generated__ folder and creates it if needed --- apps/web/scripts/compile-ajv-validators.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/web/scripts/compile-ajv-validators.js b/apps/web/scripts/compile-ajv-validators.js index 965a479d482..b8f871d4234 100644 --- a/apps/web/scripts/compile-ajv-validators.js +++ b/apps/web/scripts/compile-ajv-validators.js @@ -6,15 +6,20 @@ const Ajv = require('ajv') const standaloneCode = require('ajv/dist/standalone').default const addFormats = require('ajv-formats') const schema = require('@uniswap/token-lists/dist/tokenlist.schema.json') +const generated_path = path.join(__dirname, '../src/utils/__generated__') + +if (!fs.existsSync(generated_path)) { + fs.mkdirSync(generated_path, { recursive: true }) +} const tokenListAjv = new Ajv({ code: { source: true, esm: true } }) addFormats(tokenListAjv) const validateTokenList = tokenListAjv.compile(schema) let tokenListModuleCode = standaloneCode(tokenListAjv, validateTokenList) -fs.writeFileSync(path.join(__dirname, '../src/utils/__generated__/validateTokenList.js'), tokenListModuleCode) +fs.writeFileSync(generated_path + '/validateTokenList.js', tokenListModuleCode) const tokensAjv = new Ajv({ code: { source: true, esm: true } }) addFormats(tokensAjv) const validateTokens = tokensAjv.compile({ ...schema, required: ['tokens'] }) let tokensModuleCode = standaloneCode(tokensAjv, validateTokens) -fs.writeFileSync(path.join(__dirname, '../src/utils/__generated__/validateTokens.js'), tokensModuleCode) +fs.writeFileSync(generated_path + '/validateTokens.js', tokensModuleCode)