Skip to content

Commit e4d263e

Browse files
Adds a --clean-build flag to the build command (Synthetixio#896)
1 parent 4a16e66 commit e4d263e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

publish/src/commands/build.js

+7
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ const build = async ({
3333
showWarnings,
3434
showContractSize,
3535
useOvm,
36+
cleanBuild,
3637
} = {}) => {
3738
console.log(gray(`Starting build${useOvm ? ' using OVM' : ''}...`));
3839

40+
if (cleanBuild && fs.existsSync(buildPath)) {
41+
fs.rmdirSync(buildPath, { recursive: true });
42+
}
43+
3944
if (!fs.existsSync(buildPath)) {
4045
fs.mkdirSync(buildPath);
4146
}
47+
4248
// Flatten all the contracts.
4349
// Start with the libraries, then copy our own contracts on top to ensure
4450
// if there's a naming clash our code wins.
@@ -216,6 +222,7 @@ module.exports = {
216222
.command('build')
217223
.description('Build (flatten and compile) solidity files')
218224
.option('-b, --build-path <value>', 'Build path for built files', DEFAULTS.buildPath)
225+
.option('-c, --clean-build', 'Delete previously existing files', false)
219226
.option(
220227
'-k, --skip-unchanged',
221228
'Skip any contracts that seem as though they have not changed (infers from flattened file and does not strictly check bytecode. ⚠⚠⚠ DO NOT USE FOR PRODUCTION BUILDS.'

0 commit comments

Comments
 (0)