201
*/
202
private async mockFolder(folder: IMockFolder, parentFolder?: URI): Promise<URI> {
204
>
? URI.joinPath(parentFolder, folder.name)
205
: URI.file(folder.name);
207
>
if (!(await this.fileService.exists(folderUri))) {
208
>
try {
209
>
await this.fileService.createFolder(folderUri);
210
>
} catch (error) {
211
throw new Error(`Failed to create folder '${folderUri.fsPath}': ${error}.`);
212
}
214
>
215
>
const resolvedChildren: URI[] = [];
216
>
for (const child of folder.children) {
217
>
const childUri = URI.joinPath(folderUri, child.name);
218
>
// create child file
219
>
if ('contents' in child) {
220
>
const contents: string = (typeof child.contents === 'string')
221
? child.contents
222
: child.contents.join('\n');
224
>
await this.fileService.writeFile(childUri, VSBuffer.fromString(contents));
225
>
226
>
resolvedChildren.push(childUri);
227
>
228
>
continue;
229
>
}
230
>
231
>
// recursively create child filesystem structure
232
>
resolvedChildren.push(await this.mockFolder(child, folderUri));
233
>
}
234
>
235
>
return folderUri;
236
>
}
237
238
/**