Use Prettier for JS files (#3913)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Francisco
2023-01-04 11:03:40 -03:00
committed by GitHub
parent 88754d0b36
commit a28aafdc85
135 changed files with 2737 additions and 3121 deletions

View File

@ -5,17 +5,15 @@ const fs = require('fs');
const path = require('path');
const format = require('./format-lines');
function getVersion (path) {
function getVersion(path) {
try {
return fs
.readFileSync(path, 'utf8')
.match(/\/\/ OpenZeppelin Contracts \(last updated v[^)]+\)/)[0];
return fs.readFileSync(path, 'utf8').match(/\/\/ OpenZeppelin Contracts \(last updated v[^)]+\)/)[0];
} catch (err) {
return null;
}
}
for (const [ file, template ] of Object.entries({
for (const [file, template] of Object.entries({
'utils/math/SafeCast.sol': './templates/SafeCast.js',
'utils/structs/EnumerableSet.sol': './templates/EnumerableSet.js',
'utils/structs/EnumerableMap.sol': './templates/EnumerableMap.js',
@ -27,7 +25,7 @@ for (const [ file, template ] of Object.entries({
const version = getVersion(output);
const content = format(
'// SPDX-License-Identifier: MIT',
...(version ? [ version + ` (${file})` ] : []),
...(version ? [version + ` (${file})`] : []),
`// This file was procedurally generated from ${input}.`,
'',
require(template),