opendraft 1.4.3 → 1.4.5
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/opendraft.js +37 -2
- package/package.json +1 -1
package/bin/opendraft.js
CHANGED
|
@@ -48,7 +48,20 @@ ${PURPLE}${BOLD} ╔═══════════════════
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function checkPython() {
|
|
51
|
-
|
|
51
|
+
// Check various Python commands including versioned ones from Homebrew
|
|
52
|
+
const pythonCommands = [
|
|
53
|
+
'python3',
|
|
54
|
+
'python',
|
|
55
|
+
'python3.13',
|
|
56
|
+
'python3.12',
|
|
57
|
+
'python3.11',
|
|
58
|
+
'python3.10',
|
|
59
|
+
'python3.9',
|
|
60
|
+
'/opt/homebrew/bin/python3',
|
|
61
|
+
'/opt/homebrew/bin/python3.11',
|
|
62
|
+
'/opt/homebrew/bin/python3.12',
|
|
63
|
+
'/usr/local/bin/python3',
|
|
64
|
+
];
|
|
52
65
|
|
|
53
66
|
for (const cmd of pythonCommands) {
|
|
54
67
|
try {
|
|
@@ -91,7 +104,29 @@ function installOpendraft(pythonCmd) {
|
|
|
91
104
|
}
|
|
92
105
|
|
|
93
106
|
function runOpendraft(pythonCmd, args) {
|
|
94
|
-
|
|
107
|
+
// Try running the opendraft command directly first (installed by pip)
|
|
108
|
+
try {
|
|
109
|
+
execSync('which opendraft', { encoding: 'utf8', stdio: 'pipe' });
|
|
110
|
+
const proc = spawn('opendraft', args, {
|
|
111
|
+
stdio: 'inherit',
|
|
112
|
+
env: process.env
|
|
113
|
+
});
|
|
114
|
+
proc.on('close', (code) => {
|
|
115
|
+
process.exit(code);
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
// opendraft not in PATH, run via Python
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Fallback: run via Python with proper argument handling
|
|
123
|
+
const script = `
|
|
124
|
+
import sys
|
|
125
|
+
sys.argv = ['opendraft'] + ${JSON.stringify(args)}
|
|
126
|
+
from opendraft.cli import main
|
|
127
|
+
main()
|
|
128
|
+
`;
|
|
129
|
+
const proc = spawn(pythonCmd, ['-c', script], {
|
|
95
130
|
stdio: 'inherit',
|
|
96
131
|
env: process.env
|
|
97
132
|
});
|