| ... | @@ -74,25 +74,6 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -74,25 +74,6 @@ pub fn execute(args: [][]u8) !void { |
| 74 | }, | 74 | }, |
| 75 | } | 75 | } |
| 76 | | 76 | |
| 77 | // ask about .gitignore | | |
| 78 | if (try u.does_folder_exist(".git")) { | | |
| 79 | const do = try inquirer.forConfirm(stdout, stdin, "It appears you're using git. Do you want init to add Zigmod to your .gitignore?", gpa); | | |
| 80 | if (do) { | | |
| 81 | const exists = try u.does_file_exist(null, ".gitignore"); | | |
| 82 | const file: std.fs.File = try (if (exists) cwd.openFile(".gitignore", .{ .read = true, .write = true }) else cwd.createFile(".gitignore", .{})); | | |
| 83 | defer file.close(); | | |
| 84 | const len = try file.getEndPos(); | | |
| 85 | if (len > 0) try file.seekTo(len - 1); | | |
| 86 | const w = file.writer(); | | |
| 87 | if (len > 0 and (try file.reader().readByte()) != '\n') { | | |
| 88 | try w.writeAll("\n"); | | |
| 89 | } | | |
| 90 | if (!exists) try w.writeAll("zig-*\n"); | | |
| 91 | try w.writeAll(".zigmod\n"); | | |
| 92 | try w.writeAll("deps.zig\n"); | | |
| 93 | } | | |
| 94 | } | | |
| 95 | | | |
| 96 | // ask about LICENSE | 77 | // ask about LICENSE |
| 97 | if (!(try u.does_file_exist(null, "LICENSE"))) { | 78 | if (!(try u.does_file_exist(null, "LICENSE"))) { |
| 98 | if (detectlicense.licenses.find(license)) |text| { | 79 | if (detectlicense.licenses.find(license)) |text| { |
| ... | @@ -120,6 +101,25 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -120,6 +101,25 @@ pub fn execute(args: [][]u8) !void { |
| 120 | } | 101 | } |
| 121 | } | 102 | } |
| 122 | } | 103 | } |
| | 104 | |
| | 105 | // ask about .gitignore |
| | 106 | if (try u.does_folder_exist(".git")) { |
| | 107 | const do = try inquirer.forConfirm(stdout, stdin, "It appears you're using git. Do you want init to add Zigmod to your .gitignore?", gpa); |
| | 108 | if (do) { |
| | 109 | const exists = try u.does_file_exist(null, ".gitignore"); |
| | 110 | const file: std.fs.File = try (if (exists) cwd.openFile(".gitignore", .{ .read = true, .write = true }) else cwd.createFile(".gitignore", .{})); |
| | 111 | defer file.close(); |
| | 112 | const len = try file.getEndPos(); |
| | 113 | if (len > 0) try file.seekTo(len - 1); |
| | 114 | const w = file.writer(); |
| | 115 | if (len > 0 and (try file.reader().readByte()) != '\n') { |
| | 116 | try w.writeAll("\n"); |
| | 117 | } |
| | 118 | if (!exists) try w.writeAll("zig-*\n"); |
| | 119 | try w.writeAll(".zigmod\n"); |
| | 120 | try w.writeAll("deps.zig\n"); |
| | 121 | } |
| | 122 | } |
| 123 | } | 123 | } |
| 124 | | 124 | |
| 125 | pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void { | 125 | pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void { |