filesystem-sandbox 1.29.0 → 1.31.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.
@@ -28,17 +28,18 @@ export declare class Sandbox {
28
28
  private runOnStat;
29
29
  run<T>(fn: Func<T> | AsyncFunc<T>, relativePath?: string): Promise<T>;
30
30
  exec(command: string, args?: string[], options?: SpawnOptions): Promise<ProcessData>;
31
+ touch(filePath: string): Promise<void>;
31
32
  private _validatePathInsideSandbox;
32
33
  /**
33
34
  * Destroys all sandboxes created in this process up until now
34
35
  */
35
36
  static destroyAll(): Promise<void>;
36
37
  /**
37
- * Destroys the default base folder for sandboxes -- useful as a once-off
38
- * run before all tests to ensure that there are no lingering sandboxes
39
- * - cannot destroy sandboxes in custom paths
38
+ * Destroys the default base folder for sandboxes (or all at the provided
39
+ * path 'at') -- useful as a once-off run before all tests to ensure
40
+ * that there are no lingering sandboxes
40
41
  */
41
- static destroyAny(): Promise<void>;
42
+ static destroyAny(at?: string): Promise<void>;
42
43
  static create(at?: string): Promise<Sandbox>;
43
44
  static setBaseTargetToCurrentWorkingDirectory(): Promise<void>;
44
45
  static setBaseTargetToSystemTempFolder(): Promise<void>;
@@ -232,6 +232,9 @@ class Sandbox {
232
232
  });
233
233
  });
234
234
  }
235
+ async touch(filePath) {
236
+ await (0, yafs_1.touch)(this.fullPathFor(filePath));
237
+ }
235
238
  _validatePathInsideSandbox(t) {
236
239
  if (t.startsWith(this.path)) {
237
240
  return;
@@ -253,12 +256,13 @@ class Sandbox {
253
256
  }
254
257
  }
255
258
  /**
256
- * Destroys the default base folder for sandboxes -- useful as a once-off
257
- * run before all tests to ensure that there are no lingering sandboxes
258
- * - cannot destroy sandboxes in custom paths
259
+ * Destroys the default base folder for sandboxes (or all at the provided
260
+ * path 'at') -- useful as a once-off run before all tests to ensure
261
+ * that there are no lingering sandboxes
259
262
  */
260
- static async destroyAny() {
261
- const target = path_1.default.join(baseTarget, exports.basePrefix);
263
+ static async destroyAny(at) {
264
+ const base = at !== null && at !== void 0 ? at : baseTarget;
265
+ const target = path_1.default.join(base, exports.basePrefix);
262
266
  try {
263
267
  await (0, yafs_1.rm)(target);
264
268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "filesystem-sandbox",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "JavaScript module to provide filesystem sandboxes for testing",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,7 +10,9 @@
10
10
  "index.d.ts"
11
11
  ],
12
12
  "scripts": {
13
+ "pretest": "rimraf .jest-cache",
13
14
  "test": "jest",
15
+ "posttest": "rimraf .jest-cache",
14
16
  "prebuild": "run-p clean-dist generate-index",
15
17
  "clean-dist": "rimraf dist",
16
18
  "generate-index": "node generate-index.js",
@@ -23,6 +25,7 @@
23
25
  "release-beta": "cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\"",
24
26
  "prerelease": "run-s build test",
25
27
  "release": "cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"",
28
+ "transpile": "tsc --noEmit",
26
29
  "tsc": "tsc",
27
30
  "zarro": "zarro"
28
31
  },
@@ -38,14 +41,14 @@
38
41
  },
39
42
  "homepage": "https://github.com/fluffynuts/filesystem-sandbox#readme",
40
43
  "devDependencies": {
41
- "@faker-js/faker": "^6.0.0",
44
+ "@faker-js/faker": "^9.9.0",
42
45
  "@types/debug": "^4.1.12",
43
46
  "@types/jest": "^25.2.3",
44
47
  "@types/lodash": "^4.14.153",
45
48
  "@types/mkdirp": "^1.0.0",
46
49
  "@types/node": "^14.0.5",
47
50
  "eslint": "^7.1.0",
48
- "expect-even-more-jest": "^1.19.0",
51
+ "expect-even-more-jest": "^1.20.0",
49
52
  "expect-more-jest": "^5.1.0",
50
53
  "jest": "^28.1.1",
51
54
  "lodash": "^4.17.15",
@@ -53,7 +56,7 @@
53
56
  "ts-jest": "^28.0.4",
54
57
  "tslint": "^6.1.2",
55
58
  "typescript": "^4.6.2",
56
- "yafs": "^1.42.0",
59
+ "yafs": "^1.48.0",
57
60
  "zarro": "^1.199.0"
58
61
  },
59
62
  "dependencies": {