A tweakable fs-like that can be mounted via FUSE
Uses fuse-bindings to mount an fs
-like object via FUSE.
Differs from fs-fuse in that:
- calls can be intercepted and tweaked to adjust behaviour
- does not try to provide full support
- uses
Promise
,async
Written for my own use.
const fuseFs = new FuseFS(fsLike[, options])
creates a FuseFS object from the fs
-like object. Options are passed
to fuse-bindings
await fuseFS.mount(mountPoint)
mounts the FuseFS object at the mount point. Returns a promise of the fact that it mounted
await fuseFS,unmount
unmounts the FuseFS object, returning a promise of the fact.
fuseFS.before(method[, method...], function[, function...])
adds before intercepts for the specified methods. Returns a function to remove them.
fuseFS.after(method[, method...], function[, function...])
adds after intercepts for the specified methods. Returns a function to remove them.
Intercept functions are called in the order they are specified. The before ones are called before the call (duh!), and the after ones after the call.
They all take one parameter, and are await
ed, so can be async
. The parameter is a context object with the following:
name
- the FUSE name of the method being calledorigArgs[]
- the original args called (before any intercepts)args[]
- the args that will be used to make the call. Can be modified by before intercepts.origResults[]
- the original results from the call (before any after intercepts)results[]
- the results of the call to be sent back to the called. Can be modified by after intercepts
results
and origResults
will be undefined
for any before intercepts. If however, an intercept sets results
then no
call will be made to the fs-like, and instead it will be passed on to the chain of after intercepts.
Return values of intercept functions are ignored. Any changes must be made to the context object.
const [err, results] = await fuseFS.invoke(method, ...args)
Invokes a FUSE callback - with the chains of intercepts - and resolves to the array of values that would be sent back to FUSE