filesystem-sandbox 1.27.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,8 @@ const os = __importStar(require("os"));
34
34
  const path_1 = __importDefault(require("path"));
35
35
  const uuid_1 = require("./uuid");
36
36
  const yafs_1 = require("yafs");
37
+ const debug_1 = require("debug");
38
+ const debug = (0, debug_1.debug)("yafs");
37
39
  if (!fs_1.promises) {
38
40
  throw new Error("Yer node is olde! filesystem-sandboxes requires a Node with fs.promises");
39
41
  }
@@ -242,7 +244,12 @@ class Sandbox {
242
244
  static async destroyAll() {
243
245
  const toDestroy = sandboxes.splice(0, sandboxes.length);
244
246
  for (const sandbox of toDestroy) {
245
- await sandbox.destroy();
247
+ try {
248
+ await sandbox.destroy();
249
+ }
250
+ catch (e) {
251
+ // suppress
252
+ }
246
253
  }
247
254
  }
248
255
  /**
@@ -252,7 +259,16 @@ class Sandbox {
252
259
  */
253
260
  static async destroyAny() {
254
261
  const target = path_1.default.join(baseTarget, exports.basePrefix);
255
- await (0, yafs_1.rm)(target);
262
+ try {
263
+ await (0, yafs_1.rm)(target);
264
+ }
265
+ catch (e) {
266
+ if (e && e.code === "ENOEMPTY") {
267
+ debug(`Unable to remove all of ${target} - something is busy in there`);
268
+ return;
269
+ }
270
+ throw e;
271
+ }
256
272
  }
257
273
  static async create(at) {
258
274
  return new Sandbox(at);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "filesystem-sandbox",
3
- "version": "1.27.0",
3
+ "version": "1.29.0",
4
4
  "description": "JavaScript module to provide filesystem sandboxes for testing",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -39,6 +39,7 @@
39
39
  "homepage": "https://github.com/fluffynuts/filesystem-sandbox#readme",
40
40
  "devDependencies": {
41
41
  "@faker-js/faker": "^6.0.0",
42
+ "@types/debug": "^4.1.12",
42
43
  "@types/jest": "^25.2.3",
43
44
  "@types/lodash": "^4.14.153",
44
45
  "@types/mkdirp": "^1.0.0",
@@ -52,10 +53,11 @@
52
53
  "ts-jest": "^28.0.4",
53
54
  "tslint": "^6.1.2",
54
55
  "typescript": "^4.6.2",
55
- "yafs": "^1.40.0",
56
+ "yafs": "^1.42.0",
56
57
  "zarro": "^1.199.0"
57
58
  },
58
59
  "dependencies": {
60
+ "debug": "^4.4.1",
59
61
  "mkdirp": "^1.0.4",
60
62
  "pure-uuid": "^1.6.2",
61
63
  "rimraf": "^3.0.2"