Skip to content

Commit

Permalink
Use synthetix prettier options for proper autoformat of generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit committed Jul 19, 2022
1 parent d7a3c7c commit 48b2d2d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contracts/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const fs = require('fs');
const ethers = require('ethers');
const prettier = require('prettier');

const prettierOptions = JSON.parse(fs.readFileSync('../.prettierrc', 'utf8'));

const synthetixPath = path.dirname(require.resolve('synthetix'));
const deployed = path.join(synthetixPath, 'publish/deployed');
const networks = fs
Expand All @@ -25,7 +27,7 @@ function generateTargets(network) {
.filter(([name]) => ['name', 'source', 'address'].includes(name))
.map(([name, value]) => `export const ${name} = ${JSON.stringify(value, null, 2)};`)
.join('\n'),
{ parser: 'typescript' }
{ parser: 'typescript', ...prettierOptions }
),
'utf8'
);
Expand All @@ -49,7 +51,7 @@ function generateSources(network) {
.filter(([name]) => ['abi'].includes(name))
.map(([name, value]) => `export const ${name} = ${JSON.stringify(value, null, 2)};`)
.join('\n'),
{ parser: 'typescript' }
{ parser: 'typescript', ...prettierOptions }
),
'utf8'
);
Expand All @@ -67,7 +69,7 @@ function generateSynths(network) {
...synths.map(({ name }) => ` ${name} = ${JSON.stringify(name, null, 2)},`),
'}',
].join('\n'),
{ parser: 'typescript' }
{ parser: 'typescript', ...prettierOptions }
),
'utf8'
);
Expand Down

0 comments on commit 48b2d2d

Please sign in to comment.