@j-o-r/sh 1.1.12 → 1.1.14

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/lib/SHExecute.js +8 -0
  2. package/package.json +1 -1
package/lib/SHExecute.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { spawnSync, spawn, exec } from 'node:child_process';
2
+ import { nextTick } from 'node:process';
2
3
 
3
4
  /**
4
5
  * Kills a process and all child processes of a given process ID in Linux/Posix.
@@ -113,6 +114,13 @@ class SHExecute {
113
114
  this.#proc.stdin.end(payload);
114
115
  }
115
116
  return new Promise((resolve, reject) => {
117
+ // https://nodejs.org/docs/latest/api/child_process.html#optionsdetached
118
+ if (options.detached) {
119
+ setTimeout(() => {
120
+ resolve('');
121
+ this.#proc.unref();
122
+ }, 1000);
123
+ }
116
124
  this.#proc.on('close', (code) => {
117
125
  if (this.#forcedKill) {
118
126
  // Resolve without content
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@j-o-r/sh",
3
3
  "author": "Jorrit Duin <j-o-r@duin.work>",
4
4
  "type": "module",
5
- "version": "1.1.12",
5
+ "version": "1.1.14",
6
6
  "description": "Execute shell commands on Linux-based systems from javascript",
7
7
  "main": "lib/SH.js",
8
8
  "types": "types/SH.d.ts",