Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fromJSONFixed(vol: Volume, json: DirectoryJSON) {
const sep = "/";
for (let filename in json) {
const data = json[filename];
const isDir = data ? Object.getPrototypeOf(data) === null : data === null;
// const isDir = typeof data === "string" || ((data as any) instanceof Buffer && data !== null);
if (!isDir) {
const steps = filenameToSteps(filename);
if (steps.length > 1) {
const dirname = sep + steps.slice(0, steps.length - 1).join(sep);
// @ts-ignore
vol.mkdirpBase(dirname, 0o777);
}
vol.writeFileSync(filename, (data as any) || "");
} else {
// @ts-ignore
vol.mkdirpBase(filename, 0o777);
}
}
}