You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugin_fs.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,8 +25,11 @@ Hop over to the [Browser QuickStart](./guide-browser.md) to see how that's done.
25
25
26
26
### Implementing your own `fs` plugin
27
27
28
+
There are actually TWO ways to implement an `fs` plugin: the classic "callback" API and the newer "promise" API. If your `fs` plugin object provides a `promises` property, `isomorphic-git` will use the "promise" API _exclusively_.
28
29
29
-
An `fs` plugin must implement the following subset of node's `fs` module:
30
+
#### Using the "callback" API
31
+
32
+
A "callback" `fs` plugin must implement the following subset of node's `fs` module:
Internally, `isomorphic-git` wraps the provided "callback" API functions using [`pify`](https://www.npmjs.com/package/pify).
45
+
46
+
As of node v12 the `fs.promises` API has been stabilized. (`lightning-fs` also provides a `fs.promises` API!) Nowadays, wrapping the callback functions
47
+
with `pify` is redundant and potentially less performant than using the native promisified versions. Plus, if you're writing your own `fs` plugin,
48
+
the `fs.promises` API lets you write straightforward implementations using `async / await` without the messy optional argument handling the callback API needs.
49
+
Therefore a second API is now supported...
50
+
51
+
#### Using the "promise" API (preferred)
52
+
53
+
A "promise" `fs` plugin must implement the same set functions as a "callback" plugin, but it implements the promisified versions, and they should all be on a property called `promises`:
0 commit comments