Skip to content

Commit 9cd4c56

Browse files
Rich-HarrisRich Harris
and
Rich Harris
authored
disallow directories being created in place of files and vice versa (#296)
Co-authored-by: Rich Harris <[email protected]>
1 parent 6736ff7 commit 9cd4c56

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/routes/tutorial/[slug]/filetree/Filetree.svelte

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@
2929
collapsed,
3030
3131
add: async (name, type) => {
32-
if (!$solution[name] && !exercise.editing_constraints.create.has(name)) {
32+
const expected = $solution[name];
33+
34+
if (type !== expected.type) {
35+
modal_text = `${name.slice(exercise.scope.prefix.length)} should be a ${expected.type}, not a ${type}!`;
36+
return;
37+
}
38+
39+
if (!expected && !exercise.editing_constraints.create.has(name)) {
3340
modal_text =
3441
'Only the following files and folders are allowed to be created in this exercise:\n' +
3542
Array.from(exercise.editing_constraints.create).join('\n');

0 commit comments

Comments
 (0)