@mac-bug-screenshot/native-host 1.0.2 → 1.0.4
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/README.md +10 -1
- package/bin/install.js +27 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,4 +22,13 @@ mac-bug-screenshot-install <확장_프로그램_ID>
|
|
|
22
22
|
## 게시 정보
|
|
23
23
|
|
|
24
24
|
- npm 패키지: https://www.npmjs.com/package/@mac-bug-screenshot/native-host
|
|
25
|
-
- 현재 버전: 1.0.
|
|
25
|
+
- 현재 버전: 1.0.2
|
|
26
|
+
|
|
27
|
+
## 문제 해결
|
|
28
|
+
|
|
29
|
+
- `Native host has exited` 오류가 뜨면 최신 버전으로 업데이트 후 재등록하세요.
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g @mac-bug-screenshot/native-host@latest
|
|
32
|
+
mac-bug-screenshot-install <확장_프로그램_ID>
|
|
33
|
+
```
|
|
34
|
+
- nvm 사용 시에도 `npm root -g` 기준 경로로 자동 설정됩니다.
|
package/bin/install.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const os = require("os");
|
|
5
|
+
const { execSync } = require("child_process");
|
|
5
6
|
|
|
6
7
|
const HOST_NAME = "com.sobbangcompany.mac_bug_screenshot";
|
|
7
8
|
const ROOT_DIR = path.resolve(__dirname, "..");
|
|
8
9
|
const TEMPLATE_PATH = path.join(ROOT_DIR, "manifest.template.json");
|
|
9
|
-
const HOST_PATH =
|
|
10
|
+
const HOST_PATH = resolveGlobalHostPath();
|
|
11
|
+
const WRAPPER_DIR = path.join(os.homedir(), ".mac-bug-screenshot");
|
|
12
|
+
const WRAPPER_PATH = path.join(WRAPPER_DIR, "native-host.sh");
|
|
10
13
|
const TARGET_DIR = path.join(
|
|
11
14
|
os.homedir(),
|
|
12
15
|
"Library",
|
|
@@ -30,9 +33,19 @@ function main() {
|
|
|
30
33
|
|
|
31
34
|
const template = fs.readFileSync(TEMPLATE_PATH, "utf8");
|
|
32
35
|
const manifest = template
|
|
33
|
-
.replace(/__HOST_PATH__/g,
|
|
36
|
+
.replace(/__HOST_PATH__/g, WRAPPER_PATH)
|
|
34
37
|
.replace(/__EXTENSION_ID__/g, extensionId);
|
|
35
38
|
|
|
39
|
+
fs.mkdirSync(WRAPPER_DIR, { recursive: true });
|
|
40
|
+
const wrapperScript = [
|
|
41
|
+
"#!/bin/sh",
|
|
42
|
+
`NODE_PATH="${process.execPath}"`,
|
|
43
|
+
`HOST_PATH="${HOST_PATH}"`,
|
|
44
|
+
'exec "$NODE_PATH" "$HOST_PATH"'
|
|
45
|
+
].join("\n");
|
|
46
|
+
fs.writeFileSync(WRAPPER_PATH, wrapperScript);
|
|
47
|
+
fs.chmodSync(WRAPPER_PATH, 0o755);
|
|
48
|
+
|
|
36
49
|
fs.mkdirSync(TARGET_DIR, { recursive: true });
|
|
37
50
|
fs.writeFileSync(TARGET_PATH, manifest);
|
|
38
51
|
fs.chmodSync(HOST_PATH, 0o755);
|
|
@@ -41,4 +54,16 @@ function main() {
|
|
|
41
54
|
console.log(TARGET_PATH);
|
|
42
55
|
}
|
|
43
56
|
|
|
57
|
+
function resolveGlobalHostPath() {
|
|
58
|
+
try {
|
|
59
|
+
const npmRoot = execSync("npm root -g", { encoding: "utf8" }).trim();
|
|
60
|
+
if (npmRoot) {
|
|
61
|
+
return path.join(npmRoot, "@mac-bug-screenshot", "native-host", "host.js");
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
// fallback to local package path
|
|
65
|
+
}
|
|
66
|
+
return path.join(ROOT_DIR, "host.js");
|
|
67
|
+
}
|
|
68
|
+
|
|
44
69
|
main();
|