Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('cloudcmd: rest: mv', async (t) => {
const volume = {
'/fixture/mv.txt': 'hello',
'/fixture/tmp/a.txt': 'a',
};
const vol = Volume.fromJSON(volume, '/');
const unionFS = ufs
.use(vol)
.use(fs);
assign(unionFS, {
promises: fs.promises,
});
mockRequire('fs', unionFS);
reRequire('@cloudcmd/rename-files');
reRequire('@cloudcmd/move-files');
reRequire(restPath);
const cloudcmd = reRequire(cloudcmdPath);
const {createConfigManager} = cloudcmd;
t.test(name, async t => {
const { default: spec } = await import(resolveSample(file))
const vol = Volume.fromJSON(spec.files)
const build = Builder(
{
...spec.options,
fsa: fsa.from(vol),
},
true
)
const actual = await build(true)
const expectedFilename = resolveSample(`${name}.expected.js`)
const hasExpected = await fsa.exists(expectedFilename)
if (!hasExpected) {
await fsa.writeFile(expectedFilename, actual, 'utf8')
if (! entries.length) {
return ({
[ currentPath ]: void 0,
});
}
return Object.keys(currentStructure).reduce((acc, key) => {
return ({
...acc,
...flatten(currentStructure[key], path.join(currentPath, key)),
});
}, {});
}
return createFsFromVolume(Volume.fromJSON(flatten(tree), cwd)) as typeof fs;
}
}
export function createMemoryFileSystem(): FileSystem {
return Volume.fromJSON({}) as any
}
private createVolume(): Volume {
return Volume.fromJSON( {}, '/' );
}
import { Volume, createFsFromVolume } from "memfs";
import { patchFs } from "fs-monkey";
export const vol = Volume.fromJSON({});
export const fs = createFsFromVolume(vol);
export function withGlobalFS(thunk: () => T): T {
const unpatch = patchFs(vol);
const ret = thunk();
unpatch();
return ret;
}