Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forge: add script/ to project paths #1877

Merged
merged 4 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions cli/assets/ContractTemplate.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Script.sol";

import {Contract} from "src/Contract.sol";

contract ContractScript is Script {
function setUp() public {}

function run() public {
vm.broadcast();
new Contract();
}
}
2 changes: 1 addition & 1 deletion cli/src/cmd/forge/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl BuildArgs {
// use the path arguments or if none where provided the `src` dir
self.watch.watchexec_config(|| {
let config = Config::from(self);
vec![config.src, config.test]
vec![config.src, config.test, config.script]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

})
}
}
Expand Down
6 changes: 6 additions & 0 deletions cli/src/cmd/forge/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,18 @@ impl Cmd for InitArgs {
let test = root.join("test");
std::fs::create_dir_all(&test)?;

let script = root.join("script");
std::fs::create_dir_all(&script)?;

// write the contract file
let contract_path = src.join("Contract.sol");
std::fs::write(contract_path, include_str!("../../../assets/ContractTemplate.sol"))?;
// write the tests
let contract_path = test.join("Contract.t.sol");
std::fs::write(contract_path, include_str!("../../../assets/ContractTemplate.t.sol"))?;
// write the script
let contract_path = script.join("Contract.s.sol");
std::fs::write(contract_path, include_str!("../../../assets/ContractTemplate.s.sol"))?;

let dest = root.join(Config::FILE_NAME);
if !dest.exists() {
Expand Down
2 changes: 2 additions & 0 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ impl Config {

self.src = p(&root, &self.src);
self.test = p(&root, &self.test);
self.script = p(&root, &self.script);
self.out = p(&root, &self.out);

self.libs = self.libs.into_iter().map(|lib| p(&root, &lib)).collect();
Expand Down Expand Up @@ -594,6 +595,7 @@ impl Config {
.cache(&self.cache_path.join(SOLIDITY_FILES_CACHE_FILENAME))
.sources(&self.src)
.tests(&self.test)
.scripts(&self.script)
.artifacts(&self.out)
.libs(self.libs.clone())
.remappings(self.get_all_remappings())
Expand Down