Skip to content

Commit 18f99c9

Browse files
committed
copy empty folders
Fixes #5
1 parent f21ef7b commit 18f99c9

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/main.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ int main (string[] args) {
155155
substitutions
156156
);
157157
} catch (Error e) {
158-
if (!(e is Valdo.TemplateApplicationError.USER_QUIT))
158+
if (!(e is Valdo.TemplateApplicationError.USER_QUIT)) {
159+
stderr.printf ("Applying template failed\n");
159160
stderr.printf ("%s\n", e.message);
161+
}
160162
return 1;
161163
}
162164

src/templateengine.vala

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ namespace Valdo.TemplateEngine {
3636
enumerator.get_child (/* FIXME: non-null */ (!)finfo),
3737
cancellable,
3838
found);
39-
} else {
40-
// FIXME: non-null
41-
found[(!)finfo] = enumerator.get_child ((!)finfo);
4239
}
40+
found[(!)finfo] = enumerator.get_child ((!)finfo);
4341
}
4442
} catch (Error e) {
4543
warning ("could not get next file in dir %s", (!)dir.get_path ());
@@ -73,7 +71,8 @@ namespace Valdo.TemplateEngine {
7371
var files_list = list_files (template.directory);
7472
foreach (var template_child_info in files_list.get_keys_as_array ()) {
7573
var file_type = /* FIXME: non-null */ ((!)template_child_info).get_file_type ();
76-
if (!(file_type == FileType.REGULAR || file_type == FileType.SYMBOLIC_LINK || file_type == FileType.SHORTCUT))
74+
if (!(file_type == FileType.REGULAR || file_type == FileType.SYMBOLIC_LINK ||
75+
file_type == FileType.SHORTCUT || file_type == FileType.DIRECTORY))
7776
continue;
7877

7978
var template_child = files_list[template_child_info];
@@ -84,22 +83,27 @@ namespace Valdo.TemplateEngine {
8483
if (template_child_path_relative == "template.json")
8584
continue; // don't copy over template.json
8685

87-
// create the parent directory of the file
88-
if (project_child_parentdir != null) {
89-
DirUtils.create_with_parents ((!) (/* FIXME: non-null */ (!)project_child_parentdir).get_path (), 0755);
90-
}
91-
92-
// if this is not a template file, just copy it over
93-
if (!(template_child_path_relative in template.inputs)) {
94-
// TODO: show file copy progress
95-
template_child.copy (project_child, FileCopyFlags.NONE);
86+
if (file_type == FileType.DIRECTORY) {
87+
// create an empty directory
88+
DirUtils.create_with_parents ((!) project_child.get_path (), 0755);
9689
} else {
97-
// remove '.in' suffix if there is one
98-
var project_child_path = (!)project_child.get_path ();
99-
if (!project_child_path.has_suffix (".in"))
100-
warning ("file template %s should have a `.in` suffix", template_child_path_relative);
101-
var renamed_project_child = File.new_for_path (/\.in$/.replace (project_child_path, -1, 0, ""));
102-
template_files[template_child] = renamed_project_child;
90+
// create the parent directory of the file
91+
if (project_child_parentdir != null) {
92+
DirUtils.create_with_parents ((!) (/* FIXME: non-null */ (!)project_child_parentdir).get_path (), 0755);
93+
}
94+
95+
// if this is not a template file, just copy it over
96+
if (!(template_child_path_relative in template.inputs)) {
97+
// TODO: show file copy progress
98+
template_child.copy (project_child, FileCopyFlags.NONE);
99+
} else {
100+
// remove '.in' suffix if there is one
101+
var project_child_path = (!)project_child.get_path ();
102+
if (!project_child_path.has_suffix (".in"))
103+
warning ("file template %s should have a `.in` suffix", template_child_path_relative);
104+
var renamed_project_child = File.new_for_path (/\.in$/.replace (project_child_path, -1, 0, ""));
105+
template_files[template_child] = renamed_project_child;
106+
}
103107
}
104108
}
105109

0 commit comments

Comments
 (0)