filesystem-sandbox 1.28.0 → 1.30.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
|
|
38
|
-
* run before all tests to ensure
|
|
39
|
-
*
|
|
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>;
|
|
@@ -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
|
}
|
|
@@ -230,6 +232,9 @@ class Sandbox {
|
|
|
230
232
|
});
|
|
231
233
|
});
|
|
232
234
|
}
|
|
235
|
+
async touch(filePath) {
|
|
236
|
+
await (0, yafs_1.touch)(this.fullPathFor(filePath));
|
|
237
|
+
}
|
|
233
238
|
_validatePathInsideSandbox(t) {
|
|
234
239
|
if (t.startsWith(this.path)) {
|
|
235
240
|
return;
|
|
@@ -251,13 +256,23 @@ class Sandbox {
|
|
|
251
256
|
}
|
|
252
257
|
}
|
|
253
258
|
/**
|
|
254
|
-
* Destroys the default base folder for sandboxes
|
|
255
|
-
* run before all tests to ensure
|
|
256
|
-
*
|
|
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
|
|
257
262
|
*/
|
|
258
|
-
static async destroyAny() {
|
|
259
|
-
const
|
|
260
|
-
|
|
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);
|
|
266
|
+
try {
|
|
267
|
+
await (0, yafs_1.rm)(target);
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
if (e && e.code === "ENOEMPTY") {
|
|
271
|
+
debug(`Unable to remove all of ${target} - something is busy in there`);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
throw e;
|
|
275
|
+
}
|
|
261
276
|
}
|
|
262
277
|
static async create(at) {
|
|
263
278
|
return new Sandbox(at);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "filesystem-sandbox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"description": "JavaScript module to provide filesystem sandboxes for testing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"release-beta": "cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\"",
|
|
24
24
|
"prerelease": "run-s build test",
|
|
25
25
|
"release": "cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"",
|
|
26
|
+
"transpile": "tsc --noEmit",
|
|
26
27
|
"tsc": "tsc",
|
|
27
28
|
"zarro": "zarro"
|
|
28
29
|
},
|
|
@@ -38,13 +39,14 @@
|
|
|
38
39
|
},
|
|
39
40
|
"homepage": "https://github.com/fluffynuts/filesystem-sandbox#readme",
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@faker-js/faker": "^
|
|
42
|
+
"@faker-js/faker": "^9.9.0",
|
|
43
|
+
"@types/debug": "^4.1.12",
|
|
42
44
|
"@types/jest": "^25.2.3",
|
|
43
45
|
"@types/lodash": "^4.14.153",
|
|
44
46
|
"@types/mkdirp": "^1.0.0",
|
|
45
47
|
"@types/node": "^14.0.5",
|
|
46
48
|
"eslint": "^7.1.0",
|
|
47
|
-
"expect-even-more-jest": "^1.
|
|
49
|
+
"expect-even-more-jest": "^1.20.0",
|
|
48
50
|
"expect-more-jest": "^5.1.0",
|
|
49
51
|
"jest": "^28.1.1",
|
|
50
52
|
"lodash": "^4.17.15",
|
|
@@ -52,10 +54,11 @@
|
|
|
52
54
|
"ts-jest": "^28.0.4",
|
|
53
55
|
"tslint": "^6.1.2",
|
|
54
56
|
"typescript": "^4.6.2",
|
|
55
|
-
"yafs": "^1.
|
|
57
|
+
"yafs": "^1.47.0",
|
|
56
58
|
"zarro": "^1.199.0"
|
|
57
59
|
},
|
|
58
60
|
"dependencies": {
|
|
61
|
+
"debug": "^4.4.1",
|
|
59
62
|
"mkdirp": "^1.0.4",
|
|
60
63
|
"pure-uuid": "^1.6.2",
|
|
61
64
|
"rimraf": "^3.0.2"
|