@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.
Files changed (2) hide show
  1. package/bin/cli.js +16 -2
  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 (shouldCopy && filtered.length === 1) {
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 (shouldCopy && results.length === 1) {
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indah_sekar/os-t",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Quick troubleshooting commands for Windows, Linux & macOS. CLI tool + web app.",
5
5
  "keywords": [
6
6
  "troubleshooting",