Skip to content

Commit

Permalink
reachable errors (#10190)
Browse files Browse the repository at this point in the history
Co-authored-by: Jarred Sumner <[email protected]>
  • Loading branch information
dylan-conway and Jarred-Sumner authored Apr 13, 2024
1 parent 1820d08 commit 176af5c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cli/create_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ pub const CreateCommand = struct {
progress.refresh();

var pluckers: [1]Archive.Plucker = if (!create_options.skip_package_json)
[1]Archive.Plucker{try Archive.Plucker.init("package.json", 2048, ctx.allocator)}
[1]Archive.Plucker{try Archive.Plucker.init(comptime strings.literal(bun.OSPathChar, "package.json"), 2048, ctx.allocator)}
else
[1]Archive.Plucker{undefined};

Expand Down
2 changes: 1 addition & 1 deletion src/deps/zig
4 changes: 2 additions & 2 deletions src/libarchive/libarchive.zig
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ pub const Archive = struct {
filename_hash: u64 = 0,
found: bool = false,
fd: FileDescriptorType = .zero,
pub fn init(filepath: string, estimated_size: usize, allocator: std.mem.Allocator) !Plucker {
pub fn init(filepath: bun.OSPathSlice, estimated_size: usize, allocator: std.mem.Allocator) !Plucker {
return Plucker{
.contents = try MutableString.init(allocator, estimated_size),
.filename_hash = bun.hash(filepath),
.filename_hash = bun.hash(std.mem.sliceAsBytes(filepath)),
.fd = .zero,
.found = false,
};
Expand Down
22 changes: 21 additions & 1 deletion test/cli/install/bun-create.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { spawn, spawnSync } from "bun";
import { afterEach, beforeEach, expect, it, describe } from "bun:test";
import { bunExe, bunEnv as env } from "harness";
import { mkdtemp, realpath, rm, mkdir, stat } from "fs/promises";
import { mkdtemp, realpath, rm, mkdir, stat, exists } from "fs/promises";
import { tmpdir } from "os";
import { join } from "path";

Expand Down Expand Up @@ -100,3 +100,23 @@ it("should create template from local folder", async () => {
const dirStat = await stat(`${x_dir}/${testTemplate}`);
expect(dirStat.isDirectory()).toBe(true);
});

for (const repo of ["https://github.com/dylan-conway/create-test", "github.com/dylan-conway/create-test"]) {
it(`should create and install github template from ${repo}`, async () => {
const { stderr, stdout, exited } = spawn({
cmd: [bunExe(), "create", repo],
cwd: x_dir,
stdout: "pipe",
stderr: "pipe",
env,
});

const err = await Bun.readableStreamToText(stderr);
expect(err).not.toContain("error:");
const out = await Bun.readableStreamToText(stdout);
expect(out).toContain("Success! dylan-conway/create-test loaded into create-test");
expect(await exists(join(x_dir, "create-test", "node_modules", "jquery"))).toBe(true);

expect(await exited).toBe(0);
});
}

0 comments on commit 176af5c

Please sign in to comment.