Skip to content

Commit e9bc0f7

Browse files
committed
fix
1 parent fdc7f50 commit e9bc0f7

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/tasks.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
TASK_COMPILE,
55
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
66
} from "hardhat/builtin-tasks/task-names";
7-
import { task } from "hardhat/config";
7+
import { task, types } from "hardhat/config";
88
import { HardhatPluginError } from "hardhat/plugins";
99
import { HardhatConfig } from "hardhat/types";
1010
import { NoirCache } from "./cache";
@@ -102,10 +102,17 @@ task(TASK_CLEAN).setAction(async (_, { config }, runSuper) => {
102102

103103
task("noir-new", "Create a new Noir package")
104104
.addPositionalParam("name", "The name of the package")
105-
.addOptionalParam("lib", "If set, create a library package")
105+
.addOptionalParam(
106+
"lib",
107+
"If set, create a library package",
108+
false,
109+
types.boolean,
110+
)
106111
.addOptionalParam(
107112
"noAdd",
108113
"If set, do not add the package to the Nargo.toml workspace",
114+
false,
115+
types.boolean,
109116
)
110117
.setAction(async (args, { config }) => {
111118
const fs = await import("fs");

test/noir.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ describe("Integration tests examples", function () {
3636
expect(circuit.bytecode.length).to.be.gt(0);
3737
});
3838

39-
it("creates a package", async function () {
39+
it("creates a bin package", async function () {
4040
const name = "my_package";
4141
await this.hre.run("noir-new", { name, noAdd: true });
4242
const dir = path.join(this.hre.config.paths.noir, name);
43-
const exists = fs.existsSync(dir);
44-
expect(exists).to.be.eq(true);
43+
expect(fs.existsSync(path.join(dir, "src", "main.nr"))).to.be.eq(true);
44+
fs.rmSync(dir, { recursive: true });
45+
});
46+
47+
it("creates a lib package", async function () {
48+
const name = "my_package";
49+
await this.hre.run("noir-new", { name, lib: true, noAdd: true });
50+
const dir = path.join(this.hre.config.paths.noir, name);
51+
expect(fs.existsSync(path.join(dir, "src", "lib.nr"))).to.be.eq(true);
4552
fs.rmSync(dir, { recursive: true });
4653
});
4754

0 commit comments

Comments
 (0)