@miloya/oc-minimax-status 0.1.1 → 0.1.3
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/bin/init.js +20 -11
- package/package.json +1 -1
package/bin/init.js
CHANGED
|
@@ -28,9 +28,14 @@ function getCommandDir() {
|
|
|
28
28
|
return path.join(home, ".config", "opencode", "commands");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function getPackageDir() {
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
function getPackageDir() {
|
|
32
|
+
// When running postinstall for global install, use npm_package_json env var
|
|
33
|
+
const pkgJson = process.env.npm_package_json;
|
|
34
|
+
if (pkgJson) {
|
|
35
|
+
return path.dirname(pkgJson);
|
|
36
|
+
}
|
|
37
|
+
return process.cwd();
|
|
38
|
+
}
|
|
34
39
|
|
|
35
40
|
function updateOpencodeConfig() {
|
|
36
41
|
const configPath = getOpencodeConfigPath();
|
|
@@ -88,17 +93,21 @@ async function init() {
|
|
|
88
93
|
fs.copyFileSync(srcIndex, destIndex);
|
|
89
94
|
console.log(` [OK] Copied ${PLUGIN_NAME}.js`);
|
|
90
95
|
|
|
91
|
-
// Copy command
|
|
96
|
+
// Copy command files
|
|
92
97
|
const commandDir = getCommandDir();
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
|
|
99
|
+
if (!fs.existsSync(commandDir)) {
|
|
100
|
+
fs.mkdirSync(commandDir, { recursive: true });
|
|
101
|
+
}
|
|
95
102
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
const cmdFiles = ["minimax.md", "minimax-set.md"];
|
|
104
|
+
for (const cmdFile of cmdFiles) {
|
|
105
|
+
const srcCommand = path.join(packageDir, "commands", cmdFile);
|
|
106
|
+
const destCommand = path.join(commandDir, cmdFile);
|
|
107
|
+
if (fs.existsSync(srcCommand)) {
|
|
108
|
+
fs.copyFileSync(srcCommand, destCommand);
|
|
109
|
+
console.log(` [OK] Copied /${cmdFile.replace(".md", "")} command`);
|
|
99
110
|
}
|
|
100
|
-
fs.copyFileSync(srcCommand, destCommand);
|
|
101
|
-
console.log(` [OK] Copied /minimax command`);
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
console.log("-- Installing dependencies...");
|