@indah_sekar/os-t 1.0.3 → 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/bin/cli.js +16 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -154,6 +154,16 @@ function printResults(results) {
|
|
|
154
154
|
console.log(`\n Found: ${results.length} command(s)`);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
function executeCommand(cmd, os) {
|
|
158
|
+
const finalCmd = prepareCommand(cmd, os);
|
|
159
|
+
console.log(`\n Executing: $ ${finalCmd}\n`);
|
|
160
|
+
try {
|
|
161
|
+
execSync(finalCmd, { stdio: "inherit", shell: true });
|
|
162
|
+
} catch {
|
|
163
|
+
// execSync throws on non-zero exit, already printed by inherit
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
157
167
|
function main() {
|
|
158
168
|
if (args.includes("--help") || args.includes("-h") || args.length === 0) {
|
|
159
169
|
printHelp();
|
|
@@ -218,7 +228,9 @@ function main() {
|
|
|
218
228
|
return;
|
|
219
229
|
}
|
|
220
230
|
printResults(filtered);
|
|
221
|
-
if (
|
|
231
|
+
if (filtered.length === 1) {
|
|
232
|
+
executeCommand(filtered[0].command, filtered[0].os);
|
|
233
|
+
} else if (shouldCopy) {
|
|
222
234
|
const cmdToSend = prepareCommand(filtered[0].command, filtered[0].os);
|
|
223
235
|
const copied = copyToClipboard(cmdToSend);
|
|
224
236
|
if (copied) {
|
|
@@ -231,7 +243,9 @@ function main() {
|
|
|
231
243
|
}
|
|
232
244
|
} else {
|
|
233
245
|
printResults(results);
|
|
234
|
-
if (
|
|
246
|
+
if (results.length === 1) {
|
|
247
|
+
executeCommand(results[0].command, results[0].os);
|
|
248
|
+
} else if (shouldCopy) {
|
|
235
249
|
const cmdToSend = prepareCommand(results[0].command, results[0].os);
|
|
236
250
|
const copied = copyToClipboard(cmdToSend);
|
|
237
251
|
if (copied) {
|