Update docs
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const format = require('./format-lines');
|
||||
|
||||
function getVersion (path) {
|
||||
@ -14,16 +16,31 @@ function getVersion (path) {
|
||||
}
|
||||
|
||||
for (const [ file, template ] of Object.entries({
|
||||
'utils/math/SafeCast.sol': './templates/SafeCast',
|
||||
'mocks/SafeCastMock.sol': './templates/SafeCastMock',
|
||||
// SafeCast
|
||||
'utils/math/SafeCast.sol': './templates/SafeCast.js',
|
||||
'mocks/SafeCastMock.sol': './templates/SafeCastMock.js',
|
||||
// EnumerableSet
|
||||
'utils/structs/EnumerableSet.sol': './templates/EnumerableSet.js',
|
||||
'mocks/EnumerableSetMock.sol': './templates/EnumerableSetMock.js',
|
||||
// EnumerableMap
|
||||
'utils/structs/EnumerableMap.sol': './templates/EnumerableMap.js',
|
||||
'mocks/EnumerableMapMock.sol': './templates/EnumerableMapMock.js',
|
||||
// Checkpoints
|
||||
'utils/Checkpoints.sol': './templates/Checkpoints.js',
|
||||
'mocks/CheckpointsMock.sol': './templates/CheckpointsMock.js',
|
||||
})) {
|
||||
const path = `./contracts/${file}`;
|
||||
const version = getVersion(path);
|
||||
const script = path.relative(path.join(__dirname, '../..'), __filename);
|
||||
const input = path.join(path.dirname(script), template);
|
||||
const output = `./contracts/${file}`;
|
||||
const version = getVersion(output);
|
||||
const content = format(
|
||||
'// SPDX-License-Identifier: MIT',
|
||||
(version ? version + ` (${file})\n` : ''),
|
||||
require(template).trimEnd(),
|
||||
...(version ? [ version + ` (${file})` ] : []),
|
||||
`// This file was procedurally generated from ${input}.`,
|
||||
'',
|
||||
require(template),
|
||||
);
|
||||
|
||||
fs.writeFileSync(path, content);
|
||||
fs.writeFileSync(output, content);
|
||||
cp.execFileSync('prettier', ['--write', output]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user