Use Prettier for JS files (#3913)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -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),
|
||||
|
||||
Reference in New Issue
Block a user