@@ -117,6 +117,10 @@ exp-grouping=preserve
117
117
nested- match = align
118
118
| }
119
119
120
+ let write_crlf_on_win32 fp s =
121
+ Out_channel. with_open_text (Fpath. to_string fp) (fun oc ->
122
+ Out_channel. output_string oc s)
123
+
120
124
let () =
121
125
Arg. parse speclist anon_fun usage_msg;
122
126
if ! new_project_dir = " " then Utils. fail " NEW_PROJECT_DIR argument is missing" ;
@@ -154,15 +158,15 @@ let () =
154
158
let gitignore = Fpath. (new_project_dirp / " .gitignore" ) in
155
159
if not (Bos.OS.File. exists gitignore |> Utils. rmsg) then (
156
160
Printf. eprintf " dkcoder: create .gitignore\n %!" ;
157
- Bos.OS.File. write gitignore (String. trim contents_gitignore_untrimmed) |> Utils. rmsg);
161
+ (* Use CRLF on Windows since ".gitignore text" in .gitattributes *)
162
+ write_crlf_on_win32 gitignore (String. trim contents_gitignore_untrimmed));
158
163
159
164
(* .ocamlformat *)
160
165
let ocamlformat = Fpath. (new_project_dirp / " .ocamlformat" ) in
161
166
if not (Bos.OS.File. exists ocamlformat |> Utils. rmsg) then (
162
167
Printf. eprintf " dkcoder: create .ocamlformat\n %!" ;
163
- (* Use CRLF on Windows since .ocamlformat is ".ocamlformat text" in .gitattributes *)
164
- Out_channel. with_open_text (Fpath. to_string ocamlformat) (fun oc ->
165
- Out_channel. output_string oc (String. trim contents_ocamlformat_untrimmed)));
168
+ (* Use CRLF on Windows since ".ocamlformat text" in .gitattributes *)
169
+ write_crlf_on_win32 ocamlformat (String. trim contents_ocamlformat_untrimmed));
166
170
167
171
(* .vscode/ *)
168
172
let vscode_dirp = Fpath. (new_project_dirp / " .vscode" ) in
@@ -173,16 +177,14 @@ let () =
173
177
if not (Bos.OS.File. exists extensions_json |> Utils. rmsg) then (
174
178
Printf. eprintf " dkcoder: create .vscode/extensions.json\n %!" ;
175
179
(* Use CRLF on Windows since .json are "*.json text" in .gitattributes *)
176
- Out_channel. with_open_text (Fpath. to_string extensions_json) (fun oc ->
177
- Out_channel. output_string oc (String. trim contents_extensions_json_untrimmed)));
180
+ write_crlf_on_win32 extensions_json (String. trim contents_extensions_json_untrimmed));
178
181
179
182
(* .vscode/settings.json *)
180
183
let settings_json = Fpath. (vscode_dirp / " settings.json" ) in
181
184
if not (Bos.OS.File. exists settings_json |> Utils. rmsg) then (
182
185
Printf. eprintf " dkcoder: create .vscode/settings.json\n %!" ;
183
186
(* Use CRLF on Windows since .json are "*.json text" in .gitattributes *)
184
- Out_channel. with_open_text (Fpath. to_string settings_json) (fun oc ->
185
- Out_channel. output_string oc (String. trim contents_settings_json_untrimmed)));
187
+ write_crlf_on_win32 settings_json (String. trim contents_settings_json_untrimmed));
186
188
187
189
(* git add, git update-index *)
188
190
let project_files = [" dk" ; " dk.cmd" ; " __dk.cmake" ;
0 commit comments