Skip to content

Commit 8e48557

Browse files
Merge pull request #97 from codesandbox/binary-fix
traverse all sub dirs
2 parents 7393a91 + 019576e commit 8e48557

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

packages/import-utils/src/create-sandbox/utils/resolve.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ export function getDirectoryPaths(directories: ISandboxDirectory[]) {
77
prevPath: string,
88
directoryShortid: string | undefined
99
) => {
10-
const dir = directories.find(
11-
(d) => d.directoryShortid === directoryShortid && d.title === d.title
10+
const dirs = directories.filter(
11+
(d) => d.directoryShortid === directoryShortid
1212
);
1313

14-
if (dir) {
14+
dirs.forEach((dir) => {
1515
const dirPath = prevPath + "/" + dir.title;
1616
paths[dirPath] = dir;
1717
addDirectory(dirPath, dir.shortid);
18-
}
18+
})
1919
};
2020

2121
directories

packages/import-utils/src/utils/files/__tests__/__snapshots__/denormalize.test.ts.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ Object {
118118
"title": "index.js",
119119
"uploadId": undefined,
120120
},
121+
Object {
122+
"code": "hello4",
123+
"directoryShortid": "dir4",
124+
"isBinary": false,
125+
"sha": undefined,
126+
"shortid": "3",
127+
"title": "template.md",
128+
"uploadId": undefined,
129+
},
130+
Object {
131+
"code": "hello5",
132+
"directoryShortid": "dir5",
133+
"isBinary": false,
134+
"sha": undefined,
135+
"shortid": "4",
136+
"title": "config.yml",
137+
"uploadId": undefined,
138+
},
121139
],
122140
}
123141
`;

packages/import-utils/src/utils/files/__tests__/denormalize.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ describe("denormalize", () => {
4747
"index.js": { content: "hello", isBinary: false },
4848
"world/index.js": { content: "hello2", isBinary: false },
4949
"world/hello/index.js": { content: "hello3", isBinary: false },
50+
".github/ISSUE_TEMPLATES/template.md": { content: "hello4", isBinary: false },
51+
".github/workflows/config.yml": { content: "hello5", isBinary: false },
5052
};
5153

5254
const existingDirs = [
@@ -60,6 +62,21 @@ describe("denormalize", () => {
6062
title: "hello",
6163
shortid: "dir2",
6264
},
65+
{
66+
directoryShortid: undefined,
67+
title: ".github",
68+
shortid: "dir3",
69+
},
70+
{
71+
directoryShortid: "dir3",
72+
title: "ISSUE_TEMPLATES",
73+
shortid: "dir4",
74+
},
75+
{
76+
directoryShortid: "dir3",
77+
title: "workflows",
78+
shortid: "dir5",
79+
},
6380
];
6481

6582
const denormalized = denormalize(paths, existingDirs);

0 commit comments

Comments
 (0)