11#!/usr/bin/env node
22
3- // const cp = require('child_process');
3+ const cp = require ( 'child_process' ) ;
44const fs = require ( 'fs' ) ;
55const path = require ( 'path' ) ;
66const format = require ( './format-lines' ) ;
@@ -13,7 +13,7 @@ function getVersion(path) {
1313 }
1414}
1515
16- function generateFromTemplate ( file , template , outputPrefix = '' ) {
16+ function generateFromTemplate ( file , template , outputPrefix = '' , lint = false ) {
1717 const script = path . relative ( path . join ( __dirname , '../..' ) , __filename ) ;
1818 const input = path . join ( path . dirname ( script ) , template ) ;
1919 const output = path . join ( outputPrefix , file ) ;
@@ -27,14 +27,17 @@ function generateFromTemplate(file, template, outputPrefix = '') {
2727 ) ;
2828
2929 fs . writeFileSync ( output , content ) ;
30- // cp.execFileSync('prettier', ['--write', output]);
30+ lint && cp . execFileSync ( 'prettier' , [ '--write' , output ] ) ;
3131}
3232
33+ // Some templates needs to go through the linter after generation
34+ const needsLinter = [ 'utils/structs/CheckpointsConfidential.sol' ] ;
35+
3336// Contracts
3437for ( const [ file , template ] of Object . entries ( {
3538 'utils/structs/CheckpointsConfidential.sol' : './templates/CheckpointsConfidential.js' ,
3639} ) ) {
37- generateFromTemplate ( file , template , './contracts/' ) ;
40+ generateFromTemplate ( file , template , './contracts/' , needsLinter . includes ( file ) ) ;
3841}
3942
4043// // Tests
0 commit comments