mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-16 15:44:16 -06:00
add vfs snapshot capability for future tests
This commit is contained in:
parent
e756182e21
commit
c4f1d7755d
@ -126,6 +126,24 @@ namespace vfs {
|
||||
return this._shadowRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshots the current file system, effectively shadowing itself. This is useful for
|
||||
* generating file system patches using `.diff()` from one snapshot to the next. Performs
|
||||
* no action if this file system is read-only.
|
||||
*/
|
||||
public snapshot() {
|
||||
if (this.isReadonly) return;
|
||||
const fs = new FileSystem(this.ignoreCase, { time: this._time });
|
||||
fs._lazy = this._lazy;
|
||||
fs._cwd = this._cwd;
|
||||
fs._time = this._time;
|
||||
fs._shadowRoot = this._shadowRoot;
|
||||
fs._dirStack = this._dirStack;
|
||||
fs.makeReadonly();
|
||||
this._lazy = {};
|
||||
this._shadowRoot = fs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a shadow copy of this file system. Changes to the shadow copy do not affect the
|
||||
* original, allowing multiple copies of the same core file system without multiple copies
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user