Skip to content
Prev Previous commit
Next Next commit
Move warning to constant
  • Loading branch information
nachoiacovino committed Sep 2, 2022
commit b17d2cdee6e348012427174a3885f18c9bf0d288
4 changes: 4 additions & 0 deletions packages/cli/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ export const CREATE_MESSAGES = {
language: "What language do you want to use?",
contract: "What contract do you want to start from?",
} as const;

export const ERROR_MESSAGES = {
noConfiguration: "Failed to find a supported project configuration file in current directory"
}
3 changes: 2 additions & 1 deletion packages/cli/e2e/deploy.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
import { copyFile } from "fs/promises";
import { resolve } from "path";
import { ERROR_MESSAGES } from "../constants/constants";

// this creates an app, can take some time that's fine
jest.setTimeout(120_000);
Expand All @@ -21,7 +22,7 @@ describe("npx thirdweb deploy", () => {

expect(await exists("BasicContract.sol")).toEqual(true);

await waitForText("Failed to find a supported project configuration");
await waitForText(ERROR_MESSAGES.noConfiguration);
await writeText("y")

// wait for program to finish
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/e2e/release.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
import { copyFile } from "fs/promises";
import { resolve } from "path";
import { ERROR_MESSAGES } from "../constants/constants";

// this creates an app, can take some time that's fine
jest.setTimeout(120_000);
Expand All @@ -21,7 +22,7 @@ describe("npx thirdweb release", () => {

expect(await exists("BasicContract.sol")).toEqual(true);

await waitForText("Failed to find a supported project configuration");
await waitForText(ERROR_MESSAGES.noConfiguration);
await writeText("y")

// wait for program to finish
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/core/detection/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import FoundryDetector from "./foundry";
import HardhatDetector from "./hardhat";
import TruffleDetector from "./truffle";
import inquirer from "inquirer";
import { ERROR_MESSAGES } from "../../../constants/constants";

const { Confirm } = require("enquirer");

Expand All @@ -25,7 +26,7 @@ export default async function detect(

//if there is no project returned at all then just return unknown}
if (!possibleProjectTypes.length) {
warn("Failed to find a supported project configuration file in current directory " + path);
warn(`${ERROR_MESSAGES.noConfiguration} ${path}`);
const prompt = new Confirm({
name: "continue",
message: "Do you want to continue and compile this project with solc instead?",
Expand Down