fs-monkey is a devDependency of jaxom-ts, a typescript lib I'm building. The release was a breeaking change, but I'm not sure the nature of the breaking change. All I know is that my build on travis fails because of some internal import/export issue that breaks dependents. I use fs-monkey as a devDependency for mocha unit test and the change from 0.3.3 to 1.0.0 is at issue. The error is:
> [email protected] t /Users/Plastikfan/dev/github/js/jaxom-ts
> mocha
Error: Cannot find module './util/list'
Require stack:
- /Users/Plastikfan/dev/github/js/jaxom-ts/node_modules/fs-monkey/lib/index.js
- /Users/Plastikfan/dev/github/js/jaxom-ts/tests/cli/application.class.spec.ts
- /Users/Plastikfan/dev/github/js/jaxom-ts/node_modules/mocha/lib/mocha.js
- /Users/Plastikfan/dev/github/js/jaxom-ts/node_modules/mocha/lib/cli/one-and-dones.js
- /Users/Plastikfan/dev/github/js/jaxom-ts/node_modules/mocha/lib/cli/options.js
- /Users/Plastikfan/dev/github/js/jaxom-ts/node_modules/mocha/bin/mocha
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
...
Please can you document (or just let me know) the nature of the change and how it affects dependents. The infomation at https://github.com/streamich/fs-monkey/releases doesn't tell me what the breaking change is.
import * as memfs from 'memfs';
import { patchFs } from 'fs-monkey';
import * as fs from 'fs';
...
const vol = memfs.vol;
const patchedFS = {
writeFileSync: (path: fs.PathLike | number, data: any, options?: fs.WriteFileOptions): void => {
throw new Error(`Something went wrong writing file to ${path}`);
}
};
function setupFS (fileNames: string[], patch?: {}): memfs.IFs {
const resultFS = R.reduce((acc: { [key: string]: any }, fileName: string): { [key: string]: any } => {
const filePath = path.resolve(__dirname, fileName);
const content: string = fs.readFileSync(filePath, 'utf8');
return R.assoc(fileName, content)(acc);
}, {})(fileNames);
const volume = memfs.Volume.fromJSON(resultFS);
if (patch) {
patchFs(patch, volume); // <--- THIS INVOKES THE ERROR WHICH WORKED PRIOR TO BREAKING CHANGE
}
return memfs.createFsFromVolume(volume);
}
...
context('given: error event occurring during write', () => {
it('should: catch and report error', () => {
mfs = setupFS(['./multiple-commands.content.xml', './test.parseInfo.all.json'],
patchedFS); // <-- HERE IS THE USE OF PATCH
I've been looking at this since the release occurred and now I've reached the end of my tether, so any information you can give me would be most appreciated. I've never had a problem of an internal import/export breaking something externally, so this is new to me, cheers.