johankit 0.0.9 → 0.1.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/dist/cli/commands/tree.js +1 -0
- package/dist/core/clipboard.js +58 -4
- package/package-lock.json +4458 -0
- package/package.json +1 -1
- package/src/core/clipboard.ts +61 -3
- package/src/services/JohankitService.ts +2 -2
|
@@ -31,6 +31,7 @@ async function tree(dir) {
|
|
|
31
31
|
for (const file of project.getSourceFiles()) {
|
|
32
32
|
const absolutePath = file.getFilePath();
|
|
33
33
|
const filePath = path_1.default.relative(dir, absolutePath);
|
|
34
|
+
console.log(filePath);
|
|
34
35
|
if (filePath.includes("node_modules") || filePath.includes("/dist/")) {
|
|
35
36
|
continue;
|
|
36
37
|
}
|
package/dist/core/clipboard.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyToClipboard = void 0;
|
|
3
|
+
exports.readClipboard = exports.copyToClipboard = void 0;
|
|
4
4
|
// src/core/clipboard.ts
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
+
let memoryClipboard = "";
|
|
6
7
|
function copyToClipboard(text) {
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
8
9
|
let command = "xclip";
|
|
@@ -18,18 +19,71 @@ function copyToClipboard(text) {
|
|
|
18
19
|
const child = (0, child_process_1.spawn)(command, args, {
|
|
19
20
|
stdio: ["pipe", "ignore", "ignore"]
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
let resolved = false;
|
|
23
|
+
child.on("error", (err) => {
|
|
24
|
+
memoryClipboard = text;
|
|
25
|
+
resolved = true;
|
|
26
|
+
resolve();
|
|
27
|
+
});
|
|
22
28
|
child.stdin.on("error", (err) => {
|
|
23
29
|
if (err.code === "EPIPE") {
|
|
30
|
+
resolved = true;
|
|
24
31
|
resolve();
|
|
25
32
|
}
|
|
26
33
|
else {
|
|
27
|
-
|
|
34
|
+
memoryClipboard = text;
|
|
35
|
+
if (!resolved)
|
|
36
|
+
resolve();
|
|
28
37
|
}
|
|
29
38
|
});
|
|
30
39
|
child.stdin.write(text);
|
|
31
40
|
child.stdin.end();
|
|
32
|
-
child.on("close", () =>
|
|
41
|
+
child.on("close", () => {
|
|
42
|
+
if (!resolved)
|
|
43
|
+
resolve();
|
|
44
|
+
});
|
|
33
45
|
});
|
|
34
46
|
}
|
|
35
47
|
exports.copyToClipboard = copyToClipboard;
|
|
48
|
+
function readClipboard() {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
let command;
|
|
51
|
+
let args = [];
|
|
52
|
+
if (process.platform === "darwin") {
|
|
53
|
+
command = "pbpaste";
|
|
54
|
+
}
|
|
55
|
+
else if (process.platform === "win32") {
|
|
56
|
+
command = "powershell";
|
|
57
|
+
args = ["-Command", "Get-Clipboard"];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
command = "xclip";
|
|
61
|
+
args = ["-selection", "clipboard", "-o"];
|
|
62
|
+
}
|
|
63
|
+
const child = (0, child_process_1.spawn)(command, args, {
|
|
64
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
65
|
+
});
|
|
66
|
+
let data = "";
|
|
67
|
+
let error = "";
|
|
68
|
+
let fallback = false;
|
|
69
|
+
child.stdout.on("data", chunk => {
|
|
70
|
+
data += chunk.toString();
|
|
71
|
+
});
|
|
72
|
+
child.stderr.on("data", chunk => {
|
|
73
|
+
error += chunk.toString();
|
|
74
|
+
});
|
|
75
|
+
child.on("error", () => {
|
|
76
|
+
fallback = true;
|
|
77
|
+
resolve(memoryClipboard);
|
|
78
|
+
});
|
|
79
|
+
child.on("close", code => {
|
|
80
|
+
if (code !== 0 || fallback) {
|
|
81
|
+
resolve(memoryClipboard);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
resolve(data);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.readClipboard = readClipboard;
|