diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig index bd3fa3be3f..22bc494ae7 100644 --- a/src/cli/create_command.zig +++ b/src/cli/create_command.zig @@ -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}; diff --git a/src/deps/zig b/src/deps/zig index 7fe33d94ea..593a407f12 160000 --- a/src/deps/zig +++ b/src/deps/zig @@ -1 +1 @@ -Subproject commit 7fe33d94eaeb1af7705e9c5f43a3b243aa895436 +Subproject commit 593a407f121a2870e9c645da33c11db5e4331920 diff --git a/src/libarchive/libarchive.zig b/src/libarchive/libarchive.zig index c6ddb0c738..a1c565c44c 100644 --- a/src/libarchive/libarchive.zig +++ b/src/libarchive/libarchive.zig @@ -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, }; diff --git a/test/cli/install/bun-create.test.ts b/test/cli/install/bun-create.test.ts index 49162855f8..a8515c1d5d 100644 --- a/test/cli/install/bun-create.test.ts +++ b/test/cli/install/bun-create.test.ts @@ -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"; @@ -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); + }); +}