Skip to content

Commit 2177ace

Browse files
committed
cmd/init: write a deps.zig so zls doesn't get mad when u open the new files
1 parent 6c0021b commit 2177ace

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/cmd/init.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const time = @import("time");
99
const extras = @import("extras");
1010

1111
const u = @import("./../util/funcs.zig");
12+
const common = @import("./../common.zig");
13+
const zigmod = @import("./../lib.zig");
1214

1315
//
1416
//
@@ -288,6 +290,26 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void {
288290
);
289291
}
290292
}
293+
294+
// write a deps.zig
295+
{
296+
const alloc = gpa;
297+
const cachepath = try u.find_cachepath();
298+
const dir = std.fs.cwd();
299+
300+
var options = common.CollectOptions{
301+
.log = true,
302+
.update = false,
303+
.alloc = alloc,
304+
};
305+
const top_module = try common.collect_deps_deep(cachepath, dir, &options);
306+
307+
var list = std.ArrayList(zigmod.Module).init(alloc);
308+
try common.collect_pkgs(top_module, &list);
309+
310+
const fetch = @import("./fetch.zig");
311+
try fetch.create_depszig(alloc, cachepath, dir, top_module, &list);
312+
}
291313
}
292314

293315
pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void {

0 commit comments

Comments
 (0)