filesystem-sandbox 1.24.0 → 1.26.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.
- package/LICENSE +29 -29
- package/README.md +74 -74
- package/dist/filesystem-sandbox.d.ts +57 -57
- package/dist/filesystem-sandbox.js +274 -287
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -20
- package/dist/uuid.d.ts +1 -1
- package/dist/uuid.js +11 -11
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +62 -63
package/LICENSE
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020, Davyd McColl
|
|
4
|
-
All rights reserved.
|
|
5
|
-
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
|
8
|
-
|
|
9
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer.
|
|
11
|
-
|
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
-
this list of conditions and the following disclaimer in the documentation
|
|
14
|
-
and/or other materials provided with the distribution.
|
|
15
|
-
|
|
16
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
-
contributors may be used to endorse or promote products derived from
|
|
18
|
-
this software without specific prior written permission.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Davyd McColl
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
filesystem-sandbox
|
|
2
|
-
---
|
|
3
|
-
|
|
4
|
-

|
|
5
|
-
|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
JavaScript module to provide (insecure) filesystem sandboxes for testing
|
|
9
|
-
|
|
10
|
-
## Why?
|
|
11
|
-
Because I've needed to write tests which do file I/O and I want an easy
|
|
12
|
-
way to do that and clean up afterwards.
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
### Creation
|
|
16
|
-
```typescript
|
|
17
|
-
// create a sandbox in a folder under your repo dir:
|
|
18
|
-
const sandbox1 = await Sandbox.create();
|
|
19
|
-
|
|
20
|
-
// create a sandbox somehere specific
|
|
21
|
-
const sandbox2 = await Sandbox.create("/tmp");
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Cleanup
|
|
25
|
-
```typescript
|
|
26
|
-
const sandbox1 = await Sandbox.create();
|
|
27
|
-
const sandbox2 = await Sandbox.create();
|
|
28
|
-
const sandbox3 = await Sandbox.create();
|
|
29
|
-
|
|
30
|
-
// clean up an individual sandbox
|
|
31
|
-
await sandbox1.destroy();
|
|
32
|
-
|
|
33
|
-
// clean up all sandboxes seen in this session, eg in `afterEach`
|
|
34
|
-
await Sandbox.destroyAll();
|
|
35
|
-
|
|
36
|
-
// precautionary: destroy any sandboxes in the default location
|
|
37
|
-
// -> useful as a beforeAll in single test (beware using in jest
|
|
38
|
-
// with concurrent testing!) or in your jest setup to clean
|
|
39
|
-
// out remnants from prior interrupted sessions. Will not destroy
|
|
40
|
-
// sandboxes in custom locations
|
|
41
|
-
await Sandbox.destroyAny();
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Path resolution
|
|
45
|
-
```typescript
|
|
46
|
-
// get the full path to a file for operations not catered for
|
|
47
|
-
// by the sandbox:
|
|
48
|
-
const sandbox = await Sandbox.create();
|
|
49
|
-
const fullpath = sandbox.fullPathFor("some-file.txt");
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### File I/O
|
|
53
|
-
```typescript
|
|
54
|
-
const sandbox = Sandbox.create();
|
|
55
|
-
// write a binary file
|
|
56
|
-
const buf1 = Buffer.from([1,2,3]);
|
|
57
|
-
await sandbox.writeFile("binary.blob", buf1);
|
|
58
|
-
// write a text file
|
|
59
|
-
await sandbox.writeFile("hello.txt", "hello world");
|
|
60
|
-
// read a text file
|
|
61
|
-
const text = await sandbox.readTextFile("hello.txt");
|
|
62
|
-
// read a binary file
|
|
63
|
-
const data = await sandbox.readFile("binary.blob");
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## File operations
|
|
67
|
-
```typescript
|
|
68
|
-
const sandbox = Sandbox.create();
|
|
69
|
-
sandbox.writeFile("hello.txt", "hello world");
|
|
70
|
-
const exists = await sandbox.fileExists("hello.txt"); // true
|
|
71
|
-
const missing = await sandbox.folderExists("hello.txt"); // false: hello.txt is a file
|
|
72
|
-
const stat = await sandbox.stat("hello.txt"); // get fulll stat info
|
|
73
|
-
const noStats = await sandbox.stat("missing"); // you'll get null
|
|
74
|
-
```
|
|
1
|
+
filesystem-sandbox
|
|
2
|
+
---
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
JavaScript module to provide (insecure) filesystem sandboxes for testing
|
|
9
|
+
|
|
10
|
+
## Why?
|
|
11
|
+
Because I've needed to write tests which do file I/O and I want an easy
|
|
12
|
+
way to do that and clean up afterwards.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
### Creation
|
|
16
|
+
```typescript
|
|
17
|
+
// create a sandbox in a folder under your repo dir:
|
|
18
|
+
const sandbox1 = await Sandbox.create();
|
|
19
|
+
|
|
20
|
+
// create a sandbox somehere specific
|
|
21
|
+
const sandbox2 = await Sandbox.create("/tmp");
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Cleanup
|
|
25
|
+
```typescript
|
|
26
|
+
const sandbox1 = await Sandbox.create();
|
|
27
|
+
const sandbox2 = await Sandbox.create();
|
|
28
|
+
const sandbox3 = await Sandbox.create();
|
|
29
|
+
|
|
30
|
+
// clean up an individual sandbox
|
|
31
|
+
await sandbox1.destroy();
|
|
32
|
+
|
|
33
|
+
// clean up all sandboxes seen in this session, eg in `afterEach`
|
|
34
|
+
await Sandbox.destroyAll();
|
|
35
|
+
|
|
36
|
+
// precautionary: destroy any sandboxes in the default location
|
|
37
|
+
// -> useful as a beforeAll in single test (beware using in jest
|
|
38
|
+
// with concurrent testing!) or in your jest setup to clean
|
|
39
|
+
// out remnants from prior interrupted sessions. Will not destroy
|
|
40
|
+
// sandboxes in custom locations
|
|
41
|
+
await Sandbox.destroyAny();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Path resolution
|
|
45
|
+
```typescript
|
|
46
|
+
// get the full path to a file for operations not catered for
|
|
47
|
+
// by the sandbox:
|
|
48
|
+
const sandbox = await Sandbox.create();
|
|
49
|
+
const fullpath = sandbox.fullPathFor("some-file.txt");
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### File I/O
|
|
53
|
+
```typescript
|
|
54
|
+
const sandbox = Sandbox.create();
|
|
55
|
+
// write a binary file
|
|
56
|
+
const buf1 = Buffer.from([1,2,3]);
|
|
57
|
+
await sandbox.writeFile("binary.blob", buf1);
|
|
58
|
+
// write a text file
|
|
59
|
+
await sandbox.writeFile("hello.txt", "hello world");
|
|
60
|
+
// read a text file
|
|
61
|
+
const text = await sandbox.readTextFile("hello.txt");
|
|
62
|
+
// read a binary file
|
|
63
|
+
const data = await sandbox.readFile("binary.blob");
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## File operations
|
|
67
|
+
```typescript
|
|
68
|
+
const sandbox = Sandbox.create();
|
|
69
|
+
sandbox.writeFile("hello.txt", "hello world");
|
|
70
|
+
const exists = await sandbox.fileExists("hello.txt"); // true
|
|
71
|
+
const missing = await sandbox.folderExists("hello.txt"); // false: hello.txt is a file
|
|
72
|
+
const stat = await sandbox.stat("hello.txt"); // get fulll stat info
|
|
73
|
+
const noStats = await sandbox.stat("missing"); // you'll get null
|
|
74
|
+
```
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SpawnOptions } from "child_process";
|
|
3
|
-
import { StatsBase } from "fs";
|
|
4
|
-
export declare type Func<T> = () => T;
|
|
5
|
-
export declare type AsyncFunc<T> = () => Promise<T>;
|
|
6
|
-
export declare const basePrefix = "__sandboxes__";
|
|
7
|
-
export declare class Sandbox {
|
|
8
|
-
private readonly _path;
|
|
9
|
-
private readonly _base;
|
|
10
|
-
private readonly _at;
|
|
11
|
-
get path(): string;
|
|
12
|
-
constructor(at?: string);
|
|
13
|
-
destroy(): Promise<void>;
|
|
14
|
-
private tryDestroyAt;
|
|
15
|
-
private tryDestroyContainer;
|
|
16
|
-
private destroyFolderIfEmpty;
|
|
17
|
-
private tryDestroySelf;
|
|
18
|
-
writeFile(at: string, contents: string | Buffer | string[]): Promise<string>;
|
|
19
|
-
appendFile(at: string, contents: string | Buffer | string[]): Promise<string>;
|
|
20
|
-
mkdir(name: string): Promise<string>;
|
|
21
|
-
private resolveRelativePath;
|
|
22
|
-
readTextFile(at: string): Promise<string>;
|
|
23
|
-
readFile(at: string): Promise<Buffer>;
|
|
24
|
-
fullPathFor(relativePath: string, ...parts: string[]): string;
|
|
25
|
-
stat(at: string): Promise<StatsBase<any> | null>;
|
|
26
|
-
folderExists(at: string): Promise<boolean>;
|
|
27
|
-
fileExists(at: string): Promise<boolean>;
|
|
28
|
-
private runOnStat;
|
|
29
|
-
run<T>(fn: Func<T> | AsyncFunc<T>, relativePath?: string): Promise<T>;
|
|
30
|
-
exec(command: string, args?: string[], options?: SpawnOptions): Promise<ProcessData>;
|
|
31
|
-
private _validatePathInsideSandbox;
|
|
32
|
-
/**
|
|
33
|
-
* Destroys all sandboxes created in this process up until now
|
|
34
|
-
*/
|
|
35
|
-
static destroyAll(): Promise<void>;
|
|
36
|
-
/**
|
|
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
|
|
40
|
-
*/
|
|
41
|
-
static destroyAny(): Promise<void>;
|
|
42
|
-
static create(at?: string): Promise<Sandbox>;
|
|
43
|
-
static setBaseTargetToCurrentWorkingDirectory(): Promise<void>;
|
|
44
|
-
static setBaseTargetToSystemTempFolder(): Promise<void>;
|
|
45
|
-
static setBaseTarget(to: string): Promise<void>;
|
|
46
|
-
}
|
|
47
|
-
export interface ProcessData {
|
|
48
|
-
stdout: string[];
|
|
49
|
-
stderr: string[];
|
|
50
|
-
code: number;
|
|
51
|
-
}
|
|
52
|
-
export interface SpawnError extends Error {
|
|
53
|
-
command: string;
|
|
54
|
-
args: string[] | undefined;
|
|
55
|
-
options: SpawnOptions | undefined;
|
|
56
|
-
result: ProcessData;
|
|
57
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SpawnOptions } from "child_process";
|
|
3
|
+
import { StatsBase } from "fs";
|
|
4
|
+
export declare type Func<T> = () => T;
|
|
5
|
+
export declare type AsyncFunc<T> = () => Promise<T>;
|
|
6
|
+
export declare const basePrefix = "__sandboxes__";
|
|
7
|
+
export declare class Sandbox {
|
|
8
|
+
private readonly _path;
|
|
9
|
+
private readonly _base;
|
|
10
|
+
private readonly _at;
|
|
11
|
+
get path(): string;
|
|
12
|
+
constructor(at?: string);
|
|
13
|
+
destroy(): Promise<void>;
|
|
14
|
+
private tryDestroyAt;
|
|
15
|
+
private tryDestroyContainer;
|
|
16
|
+
private destroyFolderIfEmpty;
|
|
17
|
+
private tryDestroySelf;
|
|
18
|
+
writeFile(at: string, contents: string | Buffer | string[]): Promise<string>;
|
|
19
|
+
appendFile(at: string, contents: string | Buffer | string[]): Promise<string>;
|
|
20
|
+
mkdir(name: string): Promise<string>;
|
|
21
|
+
private resolveRelativePath;
|
|
22
|
+
readTextFile(at: string): Promise<string>;
|
|
23
|
+
readFile(at: string): Promise<Buffer>;
|
|
24
|
+
fullPathFor(relativePath: string, ...parts: string[]): string;
|
|
25
|
+
stat(at: string): Promise<StatsBase<any> | null>;
|
|
26
|
+
folderExists(at: string): Promise<boolean>;
|
|
27
|
+
fileExists(at: string): Promise<boolean>;
|
|
28
|
+
private runOnStat;
|
|
29
|
+
run<T>(fn: Func<T> | AsyncFunc<T>, relativePath?: string): Promise<T>;
|
|
30
|
+
exec(command: string, args?: string[], options?: SpawnOptions): Promise<ProcessData>;
|
|
31
|
+
private _validatePathInsideSandbox;
|
|
32
|
+
/**
|
|
33
|
+
* Destroys all sandboxes created in this process up until now
|
|
34
|
+
*/
|
|
35
|
+
static destroyAll(): Promise<void>;
|
|
36
|
+
/**
|
|
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
|
|
40
|
+
*/
|
|
41
|
+
static destroyAny(): Promise<void>;
|
|
42
|
+
static create(at?: string): Promise<Sandbox>;
|
|
43
|
+
static setBaseTargetToCurrentWorkingDirectory(): Promise<void>;
|
|
44
|
+
static setBaseTargetToSystemTempFolder(): Promise<void>;
|
|
45
|
+
static setBaseTarget(to: string): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface ProcessData {
|
|
48
|
+
stdout: string[];
|
|
49
|
+
stderr: string[];
|
|
50
|
+
code: number;
|
|
51
|
+
}
|
|
52
|
+
export interface SpawnError extends Error {
|
|
53
|
+
command: string;
|
|
54
|
+
args: string[] | undefined;
|
|
55
|
+
options: SpawnOptions | undefined;
|
|
56
|
+
result: ProcessData;
|
|
57
|
+
}
|
|
@@ -1,287 +1,274 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Sandbox = exports.basePrefix = void 0;
|
|
30
|
-
const child_process_1 = require("child_process");
|
|
31
|
-
const fs_1 = require("fs");
|
|
32
|
-
const os = __importStar(require("os"));
|
|
33
|
-
// require for "path" produces the cleanest js output
|
|
34
|
-
const path_1 = __importDefault(require("path"));
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
await this.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
async
|
|
178
|
-
at = this.resolveRelativePath(at);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
static async
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
exports.Sandbox = Sandbox;
|
|
278
|
-
function makeSpawnErrorFor(result, command, args, options) {
|
|
279
|
-
const e = new Error(`Error exit code ${result.code} for: ${command} ${(args || []).join(" ")}`);
|
|
280
|
-
return {
|
|
281
|
-
...e,
|
|
282
|
-
result,
|
|
283
|
-
command,
|
|
284
|
-
args,
|
|
285
|
-
options
|
|
286
|
-
};
|
|
287
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Sandbox = exports.basePrefix = void 0;
|
|
30
|
+
const child_process_1 = require("child_process");
|
|
31
|
+
const fs_1 = require("fs");
|
|
32
|
+
const os = __importStar(require("os"));
|
|
33
|
+
// require for "path" produces the cleanest js output
|
|
34
|
+
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const uuid_1 = require("./uuid");
|
|
36
|
+
const yafs_1 = require("yafs");
|
|
37
|
+
if (!fs_1.promises) {
|
|
38
|
+
throw new Error("Yer node is olde! filesystem-sandboxes requires a Node with fs.promises");
|
|
39
|
+
}
|
|
40
|
+
const { writeFile, readFile, stat, appendFile } = fs_1.promises;
|
|
41
|
+
async function isFolder(p) {
|
|
42
|
+
try {
|
|
43
|
+
const st = await stat(p);
|
|
44
|
+
return st && st.isDirectory();
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function readdir(p) {
|
|
51
|
+
const exists = await isFolder(p);
|
|
52
|
+
if (!exists) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return await fs_1.promises.readdir(p);
|
|
56
|
+
}
|
|
57
|
+
exports.basePrefix = "__sandboxes__";
|
|
58
|
+
let baseTarget = os.tmpdir();
|
|
59
|
+
const sandboxes = [];
|
|
60
|
+
async function writeData(fullPath, contents, writeFunction) {
|
|
61
|
+
const options = contents instanceof Buffer
|
|
62
|
+
? undefined
|
|
63
|
+
: { encoding: "utf8" };
|
|
64
|
+
if (Array.isArray(contents)) {
|
|
65
|
+
contents = contents.join("\n");
|
|
66
|
+
}
|
|
67
|
+
await writeFunction(fullPath, contents, options);
|
|
68
|
+
return fullPath;
|
|
69
|
+
}
|
|
70
|
+
class Sandbox {
|
|
71
|
+
constructor(at) {
|
|
72
|
+
this._at = at;
|
|
73
|
+
this._base = path_1.default.join(at || baseTarget, exports.basePrefix);
|
|
74
|
+
this._path = path_1.default.join(this._base, (0, uuid_1.uuid)());
|
|
75
|
+
(0, yafs_1.mkdirSync)(this._path);
|
|
76
|
+
sandboxes.push(this);
|
|
77
|
+
}
|
|
78
|
+
get path() {
|
|
79
|
+
return this._path;
|
|
80
|
+
}
|
|
81
|
+
async destroy() {
|
|
82
|
+
try {
|
|
83
|
+
await this.tryDestroySelf();
|
|
84
|
+
await this.tryDestroyContainer();
|
|
85
|
+
await this.tryDestroyAt();
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
console.warn(`sandbox destruction did not complete - if you see this regularly, please raise an issue`, e);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async tryDestroyAt() {
|
|
92
|
+
if (!this._at) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
await this.destroyFolderIfEmpty(this._at);
|
|
96
|
+
}
|
|
97
|
+
async tryDestroyContainer() {
|
|
98
|
+
await this.destroyFolderIfEmpty(this._base);
|
|
99
|
+
}
|
|
100
|
+
async destroyFolderIfEmpty(p) {
|
|
101
|
+
const contents = await (0, yafs_1.ls)(p);
|
|
102
|
+
if (!contents.length) {
|
|
103
|
+
await (0, yafs_1.rm)(p);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async tryDestroySelf() {
|
|
107
|
+
const myIndex = sandboxes.indexOf(this);
|
|
108
|
+
if (myIndex > -1) {
|
|
109
|
+
sandboxes.splice(myIndex, 1);
|
|
110
|
+
}
|
|
111
|
+
await (0, yafs_1.rm)(this._path);
|
|
112
|
+
}
|
|
113
|
+
async writeFile(at, contents) {
|
|
114
|
+
try {
|
|
115
|
+
const fullPath = this.fullPathFor(at);
|
|
116
|
+
await (0, yafs_1.mkdir)(path_1.default.dirname(fullPath));
|
|
117
|
+
contents = contents || "";
|
|
118
|
+
if (typeof contents === "string") {
|
|
119
|
+
await writeFile(fullPath, contents);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
await (0, yafs_1.writeTextFile)(fullPath, contents);
|
|
123
|
+
}
|
|
124
|
+
return fullPath;
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
throw new Error(`Unable to write file at ${at}: ${e.message || e}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async appendFile(at, contents) {
|
|
131
|
+
try {
|
|
132
|
+
await this.mkdir(path_1.default.dirname(at));
|
|
133
|
+
return await writeData(this.fullPathFor(at), contents, appendFile);
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
throw new Error(`Unable to append to file at ${at}: ${e.message || e}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async mkdir(name) {
|
|
140
|
+
const fullPath = path_1.default.join(this._path, name);
|
|
141
|
+
await (0, yafs_1.mkdir)(fullPath);
|
|
142
|
+
return fullPath;
|
|
143
|
+
}
|
|
144
|
+
resolveRelativePath(at) {
|
|
145
|
+
if (!path_1.default.isAbsolute(at)) {
|
|
146
|
+
return at;
|
|
147
|
+
}
|
|
148
|
+
const result = path_1.default.relative(this._path, at);
|
|
149
|
+
if (result.startsWith("..")) {
|
|
150
|
+
throw new Error(`${at} is outside the sandbox at ${this._path}`);
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
async readTextFile(at) {
|
|
155
|
+
return readFile(this.fullPathFor(at), { encoding: "utf8" });
|
|
156
|
+
}
|
|
157
|
+
async readFile(at) {
|
|
158
|
+
return readFile(this.fullPathFor(at));
|
|
159
|
+
}
|
|
160
|
+
fullPathFor(relativePath, ...parts) {
|
|
161
|
+
relativePath = this.resolveRelativePath(relativePath);
|
|
162
|
+
return path_1.default.join(this._path, relativePath, ...parts);
|
|
163
|
+
}
|
|
164
|
+
async stat(at) {
|
|
165
|
+
at = this.resolveRelativePath(at);
|
|
166
|
+
try {
|
|
167
|
+
return await fs_1.promises.stat(this.fullPathFor(at));
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async folderExists(at) {
|
|
174
|
+
at = this.resolveRelativePath(at);
|
|
175
|
+
return this.runOnStat(at, st => !!st && st.isDirectory());
|
|
176
|
+
}
|
|
177
|
+
async fileExists(at) {
|
|
178
|
+
at = this.resolveRelativePath(at);
|
|
179
|
+
return this.runOnStat(at, st => !!st && st.isFile());
|
|
180
|
+
}
|
|
181
|
+
async runOnStat(relativePath, fn) {
|
|
182
|
+
const st = await this.stat(relativePath);
|
|
183
|
+
return fn(st);
|
|
184
|
+
}
|
|
185
|
+
async run(fn, relativePath) {
|
|
186
|
+
const start = process.cwd();
|
|
187
|
+
try {
|
|
188
|
+
const target = relativePath
|
|
189
|
+
? path_1.default.resolve(path_1.default.join(this.path, relativePath))
|
|
190
|
+
: this.path;
|
|
191
|
+
this._validatePathInsideSandbox(target);
|
|
192
|
+
process.chdir(target);
|
|
193
|
+
return await fn();
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
process.chdir(start);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async exec(command, args, options) {
|
|
200
|
+
return await this.run(() => {
|
|
201
|
+
const spawnArgs = args || [], spawnOptions = options || {};
|
|
202
|
+
return new Promise((resolve, reject) => {
|
|
203
|
+
var _a, _b;
|
|
204
|
+
const child = (0, child_process_1.spawn)(command, spawnArgs, spawnOptions), result = {
|
|
205
|
+
stdout: [],
|
|
206
|
+
stderr: [],
|
|
207
|
+
code: -1
|
|
208
|
+
};
|
|
209
|
+
(_a = child.stderr) === null || _a === void 0 ? void 0 : _a.on("data", d => {
|
|
210
|
+
result.stderr.push(d.toString());
|
|
211
|
+
});
|
|
212
|
+
(_b = child.stdout) === null || _b === void 0 ? void 0 : _b.on("data", d => {
|
|
213
|
+
result.stdout.push(d.toString());
|
|
214
|
+
});
|
|
215
|
+
child.on("close", code => {
|
|
216
|
+
result.code = code;
|
|
217
|
+
return code
|
|
218
|
+
? reject(makeSpawnErrorFor(result, command, args, options))
|
|
219
|
+
: resolve(result);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
_validatePathInsideSandbox(t) {
|
|
225
|
+
if (t.startsWith(this.path)) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
throw new Error(`${t} is not inside sandbox at ${this.path}`);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Destroys all sandboxes created in this process up until now
|
|
232
|
+
*/
|
|
233
|
+
static async destroyAll() {
|
|
234
|
+
const toDestroy = sandboxes.splice(0, sandboxes.length);
|
|
235
|
+
for (const sandbox of toDestroy) {
|
|
236
|
+
await sandbox.destroy();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Destroys the default base folder for sandboxes -- useful as a once-off
|
|
241
|
+
* run before all tests to ensure that there are no lingering sandboxes
|
|
242
|
+
* - cannot destroy sandboxes in custom paths
|
|
243
|
+
*/
|
|
244
|
+
static async destroyAny() {
|
|
245
|
+
const target = path_1.default.join(baseTarget, exports.basePrefix);
|
|
246
|
+
await (0, yafs_1.rm)(target);
|
|
247
|
+
}
|
|
248
|
+
static async create(at) {
|
|
249
|
+
return new Sandbox(at);
|
|
250
|
+
}
|
|
251
|
+
static async setBaseTargetToCurrentWorkingDirectory() {
|
|
252
|
+
await this.setBaseTarget(process.cwd());
|
|
253
|
+
}
|
|
254
|
+
static async setBaseTargetToSystemTempFolder() {
|
|
255
|
+
await this.setBaseTarget(os.tmpdir());
|
|
256
|
+
}
|
|
257
|
+
static async setBaseTarget(to) {
|
|
258
|
+
if (!(await isFolder(to))) {
|
|
259
|
+
await (0, yafs_1.mkdir)(to);
|
|
260
|
+
}
|
|
261
|
+
baseTarget = to;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.Sandbox = Sandbox;
|
|
265
|
+
function makeSpawnErrorFor(result, command, args, options) {
|
|
266
|
+
const e = new Error(`Error exit code ${result.code} for: ${command} ${(args || []).join(" ")}`);
|
|
267
|
+
return {
|
|
268
|
+
...e,
|
|
269
|
+
result,
|
|
270
|
+
command,
|
|
271
|
+
args,
|
|
272
|
+
options
|
|
273
|
+
};
|
|
274
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./filesystem-sandbox";
|
|
2
|
-
export * from "./index";
|
|
3
|
-
export * from "./uuid";
|
|
1
|
+
export * from "./filesystem-sandbox";
|
|
2
|
+
export * from "./index";
|
|
3
|
+
export * from "./uuid";
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// this is a generated file: do not edit
|
|
18
|
-
__exportStar(require("./filesystem-sandbox"), exports);
|
|
19
|
-
__exportStar(require("./index"), exports);
|
|
20
|
-
__exportStar(require("./uuid"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// this is a generated file: do not edit
|
|
18
|
+
__exportStar(require("./filesystem-sandbox"), exports);
|
|
19
|
+
__exportStar(require("./index"), exports);
|
|
20
|
+
__exportStar(require("./uuid"), exports);
|
package/dist/uuid.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function uuid(): string;
|
|
1
|
+
export declare function uuid(): string;
|
package/dist/uuid.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uuid = void 0;
|
|
7
|
-
const pure_uuid_1 = __importDefault(require("pure-uuid"));
|
|
8
|
-
function uuid() {
|
|
9
|
-
return new pure_uuid_1.default(4).toString();
|
|
10
|
-
}
|
|
11
|
-
exports.uuid = uuid;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.uuid = void 0;
|
|
7
|
+
const pure_uuid_1 = __importDefault(require("pure-uuid"));
|
|
8
|
+
function uuid() {
|
|
9
|
+
return new pure_uuid_1.default(4).toString();
|
|
10
|
+
}
|
|
11
|
+
exports.uuid = uuid;
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./dist";
|
|
1
|
+
export * from "./dist";
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require("./dist");
|
|
1
|
+
module.exports = require("./dist");
|
package/package.json
CHANGED
|
@@ -1,64 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "filesystem-sandbox",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "JavaScript module to provide filesystem sandboxes for testing",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist/**/*",
|
|
9
|
-
"index.js",
|
|
10
|
-
"index.d.ts"
|
|
11
|
-
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"test": "jest",
|
|
14
|
-
"prebuild": "run-p clean-dist generate-index",
|
|
15
|
-
"clean-dist": "rimraf dist",
|
|
16
|
-
"generate-index": "node generate-index.js",
|
|
17
|
-
"build": "run-p tsc lint",
|
|
18
|
-
"autobuild": "nodemon -V -w src -w tests -e ts -x \"run-s -s build autobuild-message\"",
|
|
19
|
-
"autobuild-message": "node -e \"console.log('Auto-build completed', new Date());\"",
|
|
20
|
-
"lint": "tslint -p .",
|
|
21
|
-
"increment-package-version-beta": "cross-env VERSION_INCREMENT_STRATEGY=patch run-s \"zarro increment-package-json-version\"",
|
|
22
|
-
"prerelease-beta": "run-s build test",
|
|
23
|
-
"release-beta": "cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\"",
|
|
24
|
-
"prerelease": "run-s build test",
|
|
25
|
-
"release": "cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"",
|
|
26
|
-
"tsc": "tsc",
|
|
27
|
-
"zarro": "zarro"
|
|
28
|
-
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "git+ssh://git@github.com/fluffynuts/filesystem-sandbox.git"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [],
|
|
34
|
-
"author": "",
|
|
35
|
-
"license": "ISC",
|
|
36
|
-
"bugs": {
|
|
37
|
-
"url": "https://github.com/fluffynuts/filesystem-sandbox/issues"
|
|
38
|
-
},
|
|
39
|
-
"homepage": "https://github.com/fluffynuts/filesystem-sandbox#readme",
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@faker-js/faker": "^6.0.0",
|
|
42
|
-
"@types/jest": "^25.2.3",
|
|
43
|
-
"@types/lodash": "^4.14.153",
|
|
44
|
-
"@types/mkdirp": "^1.0.0",
|
|
45
|
-
"@types/node": "^14.0.5",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"expect-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "filesystem-sandbox",
|
|
3
|
+
"version": "1.26.0",
|
|
4
|
+
"description": "JavaScript module to provide filesystem sandboxes for testing",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"index.js",
|
|
10
|
+
"index.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"prebuild": "run-p clean-dist generate-index",
|
|
15
|
+
"clean-dist": "rimraf dist",
|
|
16
|
+
"generate-index": "node generate-index.js",
|
|
17
|
+
"build": "run-p tsc lint",
|
|
18
|
+
"autobuild": "nodemon -V -w src -w tests -e ts -x \"run-s -s build autobuild-message\"",
|
|
19
|
+
"autobuild-message": "node -e \"console.log('Auto-build completed', new Date());\"",
|
|
20
|
+
"lint": "tslint -p .",
|
|
21
|
+
"increment-package-version-beta": "cross-env VERSION_INCREMENT_STRATEGY=patch run-s \"zarro increment-package-json-version\"",
|
|
22
|
+
"prerelease-beta": "run-s build test",
|
|
23
|
+
"release-beta": "cross-env BETA=1 VERSION_INCREMENT_STRATEGY=patch run-s \"zarro release-npm\"",
|
|
24
|
+
"prerelease": "run-s build test",
|
|
25
|
+
"release": "cross-env VERSION_INCREMENT_STRATEGY=minor run-s \"zarro release-npm\"",
|
|
26
|
+
"tsc": "tsc",
|
|
27
|
+
"zarro": "zarro"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+ssh://git@github.com/fluffynuts/filesystem-sandbox.git"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [],
|
|
34
|
+
"author": "",
|
|
35
|
+
"license": "ISC",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/fluffynuts/filesystem-sandbox/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/fluffynuts/filesystem-sandbox#readme",
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@faker-js/faker": "^6.0.0",
|
|
42
|
+
"@types/jest": "^25.2.3",
|
|
43
|
+
"@types/lodash": "^4.14.153",
|
|
44
|
+
"@types/mkdirp": "^1.0.0",
|
|
45
|
+
"@types/node": "^14.0.5",
|
|
46
|
+
"eslint": "^7.1.0",
|
|
47
|
+
"expect-even-more-jest": "^1.19.0",
|
|
48
|
+
"expect-more-jest": "^5.1.0",
|
|
49
|
+
"jest": "^28.1.1",
|
|
50
|
+
"lodash": "^4.17.15",
|
|
51
|
+
"nodemon": "^2.0.4",
|
|
52
|
+
"ts-jest": "^28.0.4",
|
|
53
|
+
"tslint": "^6.1.2",
|
|
54
|
+
"typescript": "^4.6.2",
|
|
55
|
+
"yafs": "^1.40.0",
|
|
56
|
+
"zarro": "^1.199.0"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"mkdirp": "^1.0.4",
|
|
60
|
+
"pure-uuid": "^1.6.2",
|
|
61
|
+
"rimraf": "^3.0.2"
|
|
62
|
+
}
|
|
64
63
|
}
|