Skip to content

Commit

Permalink
Implement getSnapshot (#143)
Browse files Browse the repository at this point in the history
* Use temp-dir for real tmp directory.

* Implement getSnapshot
  • Loading branch information
mshima committed May 1, 2021
1 parent 1a0b1d0 commit 479fcde
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 123 deletions.
5 changes: 3 additions & 2 deletions lib/run-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const os = require('os');
const assert = require('assert');
const _ = require('lodash/string');
const util = require('util');
const {EventEmitter} = require('events');
const tempDirectory = require('temp-dir');

const RunResult = require('./run-result');

/**
Expand Down Expand Up @@ -344,7 +345,7 @@ RunContext.prototype.cd = function (dirPath) {
*/
RunContext.prototype.inTmpDir = function (cb) {
return this.inDir(
path.join(os.tmpdir(), crypto.randomBytes(20).toString('hex')),
path.join(tempDirectory, crypto.randomBytes(20).toString('hex')),
cb
);
};
Expand Down
4 changes: 4 additions & 0 deletions lib/run-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ module.exports = class RunResult {
);
}

getSnapshot() {
return this.fs.dump(this.cwd);
}

/**
* Prints files names and contents from mem-fs
* @param {...string} files - Files to print or empty for entire mem-fs
Expand Down
Loading

0 comments on commit 479fcde

Please sign in to comment.