Skip to content

Commit 0ef0e4e

Browse files
committed
fix
1 parent 13a64b2 commit 0ef0e4e

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
@@ -3,7 +3,7 @@ import {
33
TASK_COMPILE,
44
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
55
} from "hardhat/builtin-tasks/task-names";
6-
import { task } from "hardhat/config";
6+
import { task, types } from "hardhat/config";
77
import { HardhatPluginError } from "hardhat/plugins";
88
import { HardhatConfig } from "hardhat/types";
99
import { NoirCache } from "./cache";
@@ -67,10 +67,17 @@ task(TASK_CLEAN).setAction(async (_, { config }, runSuper) => {
6767

6868
task("noir-new", "Create a new Noir package")
6969
.addPositionalParam("name", "The name of the package")
70-
.addOptionalParam("lib", "If set, create a library package")
70+
.addOptionalParam(
71+
"lib",
72+
"If set, create a library package",
73+
false,
74+
types.boolean,
75+
)
7176
.addOptionalParam(
7277
"noAdd",
7378
"If set, do not add the package to the Nargo.toml workspace",
79+
false,
80+
types.boolean,
7481
)
7582
.setAction(async (args, { config }) => {
7683
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)