Commit 616d3b3b authored by Caleb C. Sander's avatar Caleb C. Sander
Browse files

Fix #6

parent 8bf9e603
No related merge requests found
Showing with 13 additions and 0 deletions
+13 -0
......@@ -264,6 +264,19 @@ Note that these functions expect diffs in the form of `FileDiffs` objects, which
You don't need to understand the code behind these functions, but I think the diffing algorithm is really cool, so please ask me if you want to know more!
## Filesystem functions
Node.js provides an extensive set of functions for filesystem operations (reading and writing files, adding and removing directories, etc.).
The full set of functions can be found in the [documentation for the `fs` module](https://nodejs.org/api/fs.html).
All the functions have versions (in `require('fs').promises`, referred to by the documentation as `fsPromises`) that return `Promise`s, which are convenient to use with `async`-`await`.
The callback versions of the functions have better examples of what arguments you can pass, so I recommend reading their documentation.
Here are the filesystem operations I used, but you are welcome to use others:
- [`fsPromises.access()`](https://nodejs.org/api/fs.html#fs_fspromises_access_path_mode): checks whether a file exists (the `Promise` will reject if it doesn't)
- [`fsPromises.mkdir()`](https://nodejs.org/api/fs.html#fs_fspromises_mkdir_path_options): makes a new (empty) directory
- [`fsPromises.readFile()`](https://nodejs.org/api/fs.html#fs_fspromises_readfile_path_options): reads the entire contents of a file as bytes or as a string (if you use encoding `'utf8'`)
- [`fsPromises.writeFile()`](https://nodejs.org/api/fs.html#fs_fspromises_writefile_file_data_options): sets the contents of a file, creating the file if it doesn't exist
## Going further
If you are interested and want to add more to the VC project, try adding support for "branches".
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment