first-base 1.5.1 → 1.6.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/.node-version +1 -1
- package/.npm-version +1 -1
- package/README.md +33 -0
- package/dist/find-root-dir.js +3 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -1
- package/dist/index.js.flow +2 -0
- package/package.json +11 -9
package/.node-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v24.13.0
|
package/.npm-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
11.6.2
|
package/README.md
CHANGED
|
@@ -137,6 +137,39 @@ run.kill(); // Kill with SIGINT
|
|
|
137
137
|
run.kill("SIGKILL"); // Kill with SIGKILL
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
+
### `RunContext#cleanResult()`
|
|
141
|
+
|
|
142
|
+
A function which returns a new object with the same shape as `RunContext#result` but with its stdout/stderr passed through the `sanitizers` Array (see below).
|
|
143
|
+
|
|
144
|
+
Unlike `result`, this object does NOT get updated over time as the process runs.
|
|
145
|
+
|
|
146
|
+
### `sanitizers: Array<(string) => string>`
|
|
147
|
+
|
|
148
|
+
An array of functions that will be run on stdout/stderr when calling
|
|
149
|
+
`RunContext#cleanResult()`.
|
|
150
|
+
|
|
151
|
+
By default, it contains 5 functions, which are run in order:
|
|
152
|
+
|
|
153
|
+
- `stripAnsi`: Removes ANSI control characters
|
|
154
|
+
- `replaceRootDir`: Replaces eg `/home/suchipi/Code/first-base/src/index.js` with `<rootDir>/src/index.js`
|
|
155
|
+
- This function searches upwards for the root dir using a heuristic, and caches results in the {@link Map} `replaceRootDir.cache`.
|
|
156
|
+
- The heuristic is:
|
|
157
|
+
- Look upwards for a folder containing `.git` or `.hg`
|
|
158
|
+
- if none is found, look upwards for a folder containing `package-lock.json`, `.gitignore` or `.hgignore`,
|
|
159
|
+
- if none is found, look upwards for a folder containing `package.json` or `README.md`
|
|
160
|
+
- if none is found, consider the present working directory to be the root dir.
|
|
161
|
+
- `replaceCwd`: Replaces the current working directory with `<cwd>`
|
|
162
|
+
- `collapseStackTrace`: For Node.JS-style stack traces, replaces the long chain of "at ..." lines with a single "at somewhere" line
|
|
163
|
+
- `omitThrowLineNumber`: For Node.JS error source display, removes the line number
|
|
164
|
+
|
|
165
|
+
You can remove them or replace them or add to them by mutating the `sanitizers` Array.
|
|
166
|
+
|
|
167
|
+
### `allInflightRunContexts: Set<RunContext>`
|
|
168
|
+
|
|
169
|
+
All runs that have been spawned which haven't reached completion (see `RunContext#completion`).
|
|
170
|
+
|
|
171
|
+
It may be beneficial to clean these up in a test timeout handler or etc.
|
|
172
|
+
|
|
140
173
|
## License
|
|
141
174
|
|
|
142
175
|
MIT
|
package/dist/find-root-dir.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _createForOfIteratorHelper(
|
|
4
|
-
function _unsupportedIterableToArray(
|
|
5
|
-
function _arrayLikeToArray(
|
|
3
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
6
|
var fs = require("fs");
|
|
7
7
|
var _require = require("nice-path"),
|
|
8
8
|
Path = _require.Path;
|
package/dist/index.d.ts
CHANGED
|
@@ -64,3 +64,10 @@ export const spawn: ((cmd: string) => RunContext) &
|
|
|
64
64
|
* You can remove them or replace them or add to them by mutating the `sanitizers` Array.
|
|
65
65
|
*/
|
|
66
66
|
export const sanitizers: Array<(str: string) => string>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* All runs that have been spawned which haven't reached completion.
|
|
70
|
+
*
|
|
71
|
+
* It may be beneficial to clean these up in a test timeout handler or etc.
|
|
72
|
+
*/
|
|
73
|
+
export const allInflightRunContexts: Set<RunContext>;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var normalSpawn = require("child_process").spawn;
|
|
|
5
5
|
var stripAnsi = require("strip-ansi");
|
|
6
6
|
var _require = require("./sanitizers"),
|
|
7
7
|
sanitizers = _require.sanitizers;
|
|
8
|
+
var allInflightRunContexts = new Set();
|
|
8
9
|
|
|
9
10
|
// Run a child process and return a "run context" object
|
|
10
11
|
// to interact with it. Function signature is the same as
|
|
@@ -147,6 +148,7 @@ var spawn = function spawn(cmd, argsOrOptions, passedOptions) {
|
|
|
147
148
|
unreffable = child;
|
|
148
149
|
}
|
|
149
150
|
running = true;
|
|
151
|
+
allInflightRunContexts.add(runContext);
|
|
150
152
|
var checkForPendingOutputRequestsToResolve = function checkForPendingOutputRequestsToResolve() {
|
|
151
153
|
pendingOutputContainsRequests.forEach(function (request) {
|
|
152
154
|
if (typeof request.value === "string") {
|
|
@@ -191,6 +193,7 @@ var spawn = function spawn(cmd, argsOrOptions, passedOptions) {
|
|
|
191
193
|
debugLog("Process ".concat(reason));
|
|
192
194
|
debugLog(runContext.result);
|
|
193
195
|
running = false;
|
|
196
|
+
allInflightRunContexts["delete"](runContext);
|
|
194
197
|
resolve();
|
|
195
198
|
pendingOutputContainsRequests.forEach(function (request) {
|
|
196
199
|
request.reject(new Error("Child process ".concat(reason, " before its output contained the requested content: ").concat(request.value)));
|
|
@@ -209,5 +212,6 @@ var spawn = function spawn(cmd, argsOrOptions, passedOptions) {
|
|
|
209
212
|
};
|
|
210
213
|
module.exports = {
|
|
211
214
|
spawn: spawn,
|
|
212
|
-
sanitizers: sanitizers
|
|
215
|
+
sanitizers: sanitizers,
|
|
216
|
+
allInflightRunContexts: allInflightRunContexts
|
|
213
217
|
};
|
package/dist/index.js.flow
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "first-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Integration testing for CLI applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -10,21 +10,23 @@
|
|
|
10
10
|
"author": "Lily Skye <me@suchipi.com>",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"node-pty": "^1.0.0",
|
|
14
13
|
"strip-ansi": "^5.0.0",
|
|
15
|
-
"nice-path": "^2.
|
|
14
|
+
"nice-path": "^3.2.2"
|
|
15
|
+
},
|
|
16
|
+
"optionalDependencies": {
|
|
17
|
+
"node-pty": "^1.0.0"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
18
|
-
"@babel/cli": "^7.
|
|
19
|
-
"@babel/core": "^7.
|
|
20
|
-
"@babel/preset-env": "^7.
|
|
20
|
+
"@babel/cli": "^7.28.6",
|
|
21
|
+
"@babel/core": "^7.29.0",
|
|
22
|
+
"@babel/preset-env": "^7.29.0",
|
|
21
23
|
"babel-core": "^7.0.0-bridge.0",
|
|
22
|
-
"babel-jest": "^
|
|
24
|
+
"babel-jest": "^30.2.0",
|
|
23
25
|
"eslint": "^8.56.0",
|
|
24
26
|
"eslint-config-unobtrusive": "^1.2.5",
|
|
25
27
|
"eslint-plugin-import": "^2.29.1",
|
|
26
|
-
"jest": "^
|
|
27
|
-
"prettier": "^3.
|
|
28
|
+
"jest": "^30.2.0",
|
|
29
|
+
"prettier": "^3.8.1"
|
|
28
30
|
},
|
|
29
31
|
"scripts": {
|
|
30
32
|
"build": "mkdir -p dist; rm -rf dist/*; babel src --out-dir dist && cp src/index.js.flow dist/ && cp src/index.d.ts dist/",
|