dashcam 0.4.0 → 0.4.2
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/index.js +4 -2
- package/package.json +2 -1
- package/recorder.js +21 -6
package/index.js
CHANGED
|
@@ -4,6 +4,8 @@ const fs = require("fs");
|
|
|
4
4
|
const crypto = require("crypto");
|
|
5
5
|
const lib = require("./lib");
|
|
6
6
|
const Recorder = require("./recorder");
|
|
7
|
+
const packageMetadata = require("./package.json");
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
if (module.parent) {
|
|
9
11
|
module.exports = lib;
|
|
@@ -17,7 +19,7 @@ let stdin = "";
|
|
|
17
19
|
program
|
|
18
20
|
.name("dashcam")
|
|
19
21
|
.description("Capture the steps to reproduce every bug.")
|
|
20
|
-
.version(
|
|
22
|
+
.version(packageMetadata.version);
|
|
21
23
|
|
|
22
24
|
program.showHelpAfterError();
|
|
23
25
|
|
|
@@ -70,7 +72,7 @@ program
|
|
|
70
72
|
dashcam.onConnected = () => dashcam.emit("track-cli", logFile);
|
|
71
73
|
fs.appendFileSync(logFile, "");
|
|
72
74
|
const recorder = new Recorder(logFile);
|
|
73
|
-
recorder.start();
|
|
75
|
+
await recorder.start();
|
|
74
76
|
} catch (e) {
|
|
75
77
|
console.log("Error: ", e);
|
|
76
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dashcam",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Fix bugs, close pulls, and update your team with desktop instant replay.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"cli-color": "^2.0.3",
|
|
17
17
|
"commander": "^9.4.0",
|
|
18
|
+
"find-process": "^1.4.7",
|
|
18
19
|
"husky": "^7.0.4",
|
|
19
20
|
"node-ipc": "^10.1.0",
|
|
20
21
|
"node-pty-prebuilt-multiarch": "^0.10.1-pre.5",
|
package/recorder.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const pty = require("node-pty-prebuilt-multiarch");
|
|
3
|
+
const process = require("process");
|
|
4
|
+
const find = require("find-process");
|
|
3
5
|
|
|
4
6
|
class Recorder {
|
|
5
7
|
#ptyProcess = null;
|
|
@@ -24,23 +26,36 @@ class Recorder {
|
|
|
24
26
|
fs.appendFileSync(this.#logFile, data, "ascii");
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
start() {
|
|
28
|
-
console.log(
|
|
29
|
-
"This session is being recorded by Dashcam and dumped to",
|
|
30
|
-
this.#logFile
|
|
31
|
-
);
|
|
29
|
+
async start() {
|
|
30
|
+
console.log("This session is being recorded by Dashcam");
|
|
32
31
|
console.log("Type `exit` to stop recording");
|
|
33
32
|
|
|
34
33
|
// TODO: Find a way to consistently get the current shell this is running from
|
|
35
34
|
// instead of using the default user shell (Maybe use parent processId to find
|
|
36
35
|
// the process filepath)
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
const shell = (
|
|
38
|
+
process.env.SHELL ||
|
|
39
|
+
(await find("pid", process.ppid).then((arr) => arr[0].bin)) ||
|
|
40
|
+
""
|
|
41
|
+
).trim();
|
|
42
|
+
|
|
43
|
+
if (!shell) throw new Error("Could not detect the current shell");
|
|
44
|
+
|
|
38
45
|
const args = [];
|
|
39
46
|
if (!shell.toLowerCase().includes("powershell")) args.push("-l");
|
|
40
47
|
this.#ptyProcess = pty.spawn(shell, args, {
|
|
41
48
|
// Inject a terminal variable to let the child processes know
|
|
42
49
|
// of the active recording so they we don't record recursively
|
|
43
50
|
env: { ...process.env, DASHCAM_TERMINAL_RECORDING: "TRUE" },
|
|
51
|
+
cols: process.stdout.columns,
|
|
52
|
+
rows: process.stdout.rows,
|
|
53
|
+
cwd: process.cwd(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
process.stdout.on("resize", () => {
|
|
57
|
+
this.#ptyProcess.cols = process.stdout.columns;
|
|
58
|
+
this.#ptyProcess.rows = process.stdout.rows;
|
|
44
59
|
});
|
|
45
60
|
|
|
46
61
|
process.stdin.on("data", this.#onInput.bind(this));
|