Rollback
Rollback the rock!
Undo pesky file system mutations with ease.
Installation
npm i -s rollback
Both typescript and javascript support come out of the box.
Basic Usage
Asynchronous API
Take a snapshot of a directory.
;; snapshot.then;
Take a snapshot of a file.
;; snapshotFile.then;
Synchronous API
Take a snapshot of a directory.
;; ;writeFileSync'/some/directory/myFile', 'some updates';snap.rollbackSync;
Take a snapshot of a file.
;; ;writeFileSync'/some/file.txt', 'some updates';snap.rollbackSync;
Advanced Usage
Rollback exposes four base methods: snapshot
, snapshotSync
, snapshotFile
, and snapshotFileSync
.
All methods accept all configuration options exposed by tmp.
Additionally the following options from fs-extra's copy are supported:
preserveTimestamps, filter, recursive
(recursive
is only supported for snapshot
and snapshotSync
)
snapshot
and snapshotFile
return a Promise which resolves with a Snapshot
object.
snapshotSync
and snapshotFileSync
return a Snapshot
directly.
Snapshot
A Snapshot
object has the following properties:
property | type | description |
---|---|---|
path |
string |
the path of the temporary directory |
cleanup |
() => void |
manually cleans up the temporary directory |
rollback |
(options?: RollbackOptions) => Promise<void> |
asynchronously rolls back any changes to the snapshot |
rollbackSync |
(options?: RollbackOptions) => void |
synchronously rolls back any changes to the snapshot |
RollbackOptions
takes the following form:
The default for rollback options is whatever was specified in the snapshot
, snapshotSync
, snapshotFile
, or snapshotFileSync
invocation that generated the Snapshot
object.
API Documentation
License
Licensed under MIT