A TypeScript library abstracting the Node filesystem APIs. We use it for three main reasons:
Our library has two path types,
PortablePath. Most interfaces only accept the later, and instances of the former need to be transformed back and forth using our type-safe utilities before being usable.
The FSLib implements various transparent filesystem layers for a variety of purposes. For instance we use it in Yarn in order to abstract away the zip archive manipulation logic, which is implemented in
ZipFS and exposed through a Node-like interface (called
FakeFS implementations can be transparently layered on top of the builtin Node
fs module, and that's for instance how we can add support for in-zip package loading without you having to care about the exact package format.
All methods from the
FakeFS interface are promisified by default (and suffixed for greater clarity, for instance we offer both
- MountedFS: MountableFS
factoryPromise: (baseFs: FakeFS<PortablePath>, path: PortablePath) => Promise<() => MountedFS>
factorySync: (baseFs: FakeFS<PortablePath>, path: PortablePath) => MountedFS
optionalfilter?: RegExp | null
A function that will be called to figure out the segment of a path that represents a mount point.
It must return a strict prefix of the original path, or
nullif the path isn’t part of a mount archive.
Maximum age of the child filesystem, after which they will be discarded. Each new access resets this time.
Only used if
useCacheis set to
optionaltypeCheck?: number | null
close: () => void