1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-mobile/utils/fs-driver/testUtil/createFilesFromPathRecord.ts

14 lines
457 B
TypeScript

import shim from '@joplin/lib/shim';
import { join, dirname } from 'path';
const createFilesFromPathRecord = async (baseDir: string, fileContents: Record<string, string>) => {
for (const relativePath in fileContents) {
const targetPath = join(baseDir, relativePath);
await shim.fsDriver().mkdir(dirname(targetPath));
await shim.fsDriver().writeFile(targetPath, fileContents[relativePath], 'utf-8');
}
};
export default createFilesFromPathRecord;