Skip to content

Commit

Permalink
fix pre-fixture for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Oct 17, 2020
1 parent 6e448a5 commit a8f2d87
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Nomic Labs LLC
Copyright (c) 2020 Ronan Sandford

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "buidler-deploy",
"version": "0.6.0-beta.29",
"version": "0.6.0-beta.30",
"description": "Buidler Plugin For Replicable Deployments And Tests",
"repository": "github:wighawag/buidler-deploy",
"author": "wighawag",
Expand Down
15 changes: 13 additions & 2 deletions src/DeploymentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export class DeploymentsManager {
tags?: string | string[],
options?: { fallbackToGlobal: boolean }
) => {
await this.setup();
options = { fallbackToGlobal: true, ...options };
if (typeof tags === "string") {
tags = [tags];
Expand Down Expand Up @@ -1055,9 +1056,19 @@ export class DeploymentsManager {

private async setup() {
if (!this.db.deploymentsLoaded) {
if (process.env.BUIDLER_DEPLOY_ALL) {
await this.env.run("deploy");
if (process.env.BUIDLER_DEPLOY_FIXTURE) {
if (!process.env.BUIDLER_DEPLOY_NO_COMPILE) {
// console.log("compiling...");
await this.env.run("compile");
}
this.db.deploymentsLoaded = true;
// console.log("running global fixture....");
await this.env.deployments.fixture();
} else {
if (process.env.BUIDLER_DEPLOY_COMPILE) {
// console.log("compiling...");
await this.env.run("compile");
}
await this.loadDeployments();
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,13 @@ export default function() {
});

task(TASK_TEST, "Runs mocha tests")
.addFlag("deploy", "run all deployments before tests")
.addFlag("fixture", "run the global fixture before tests")
.setAction(async (args, bre, runSuper) => {
if (args.deploy || process.env.BUIDLER_DEPLOY_ALL) {
await bre.run("deploy", { noCompile: args.noCompile });
if (args.fixture || process.env.BUIDLER_DEPLOY_FIXTURE) {
if (!args.noCompile && !process.env.BUIDLER_DEPLOY_NO_COMPILE) {
await bre.run("compile");
}
await bre.deployments.fixture();
return runSuper({ ...args, noCompile: true });
} else {
return runSuper(args);
Expand Down

0 comments on commit a8f2d87

Please sign in to comment.