spawn-term 1.1.5 → 1.1.7

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.
@@ -42,5 +42,5 @@ function _interop_require_default(obj) {
42
42
  };
43
43
  }
44
44
  var major = +process.versions.node.split('.')[0];
45
- var _default = major > 14 ? _spawnTerminalts.default : undefined;
45
+ var _default = major > 18 ? _spawnTerminalts.default : undefined;
46
46
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["export { default as figures } from './lib/figures.ts';\nexport { default as formatArguments } from './lib/formatArguments.ts';\nexport * from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\n\nimport { default as spawnTerminal } from './spawnTerminal.ts';\nexport default major > 14 ? spawnTerminal : (undefined as typeof spawnTerminal);\n"],"names":["figures","formatArguments","major","process","versions","node","split","spawnTerminal","undefined"],"mappings":";;;;;;;;;;;QAOA;eAAA;;QAPoBA;eAAAA,kBAAO;;QACPC;eAAAA,0BAAe;;;gEADA;wEACQ;qBAC7B;sEAI2B;;;;;;;;;;;;;;;;;;;AAFzC,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IAGlD,WAAeJ,QAAQ,KAAKK,wBAAa,GAAIC"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["export { default as figures } from './lib/figures.ts';\nexport { default as formatArguments } from './lib/formatArguments.ts';\nexport * from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\n\nimport { default as spawnTerminal } from './spawnTerminal.ts';\nexport default major > 18 ? spawnTerminal : (undefined as typeof spawnTerminal);\n"],"names":["figures","formatArguments","major","process","versions","node","split","spawnTerminal","undefined"],"mappings":";;;;;;;;;;;QAOA;eAAA;;QAPoBA;eAAAA,kBAAO;;QACPC;eAAAA,0BAAe;;;gEADA;wEACQ;qBAC7B;sEAI2B;;;;;;;;;;;;;;;;;;;AAFzC,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IAGlD,WAAeJ,QAAQ,KAAKK,wBAAa,GAAIC"}
@@ -57,6 +57,9 @@ function worker(command, args, spawnOptions, options, callback) {
57
57
  }).catch(callback);
58
58
  }
59
59
  function spawnTerminal(command, args, spawnOptions, options, callback) {
60
+ if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) {
61
+ throw new Error("Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output.");
62
+ }
60
63
  if (typeof options === 'function') {
61
64
  callback = options;
62
65
  options = {};
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/spawnTerminal.ts"],"sourcesContent":["import type { SpawnOptions, SpawnResult, TerminalCallback, TerminalOptions } from './types.ts';\n\nfunction worker(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n import('./worker.js')\n .then((fn) => {\n fn.default(command, args, spawnOptions, options, callback);\n })\n .catch(callback);\n}\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | TerminalCallback, callback?: TerminalCallback): undefined | Promise<SpawnResult> {\n if (typeof options === 'function') {\n callback = options as TerminalCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback as TerminalCallback);\n return new Promise((resolve, reject) =>\n worker(command, args, spawnOptions, options, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n}\n"],"names":["spawnTerminal","worker","command","args","spawnOptions","options","callback","then","fn","default","catch","Promise","resolve","reject","err","result"],"mappings":";;;;+BAUA;;;eAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AARxB,SAASC,OAAOC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IAC/H;uDAAA,QAAO;OACJC,IAAI,CAAC,SAACC;QACLA,GAAGC,OAAO,CAACP,SAASC,MAAMC,cAAcC,SAASC;IACnD,GACCI,KAAK,CAACJ;AACX;AAEe,SAASN,cAAcE,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA4C,EAAEC,QAA2B;IAC1K,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,OAAOC,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIK,QAAQ,SAACC,SAASC;eAC3BZ,OAAOC,SAASC,MAAMC,cAAcC,SAAS,SAACS,KAAKC;YACjDD,MAAMD,OAAOC,OAAOF,QAAQG;QAC9B;;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/spawnTerminal.ts"],"sourcesContent":["import type { SpawnOptions, SpawnResult, TerminalCallback, TerminalOptions } from './types.ts';\n\nfunction worker(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n import('./worker.js')\n .then((fn) => {\n fn.default(command, args, spawnOptions, options, callback);\n })\n .catch(callback);\n}\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | TerminalCallback, callback?: TerminalCallback): undefined | Promise<SpawnResult> {\n if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) {\n throw new Error(\"Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output.\");\n }\n\n if (typeof options === 'function') {\n callback = options as TerminalCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback as TerminalCallback);\n return new Promise((resolve, reject) =>\n worker(command, args, spawnOptions, options, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n}\n"],"names":["spawnTerminal","worker","command","args","spawnOptions","options","callback","then","fn","default","catch","stdio","encoding","Error","Promise","resolve","reject","err","result"],"mappings":";;;;+BAUA;;;eAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AARxB,SAASC,OAAOC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IAC/H;uDAAA,QAAO;OACJC,IAAI,CAAC,SAACC;QACLA,GAAGC,OAAO,CAACP,SAASC,MAAMC,cAAcC,SAASC;IACnD,GACCI,KAAK,CAACJ;AACX;AAEe,SAASN,cAAcE,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA4C,EAAEC,QAA2B;IAC1K,IAAIF,aAAaO,KAAK,KAAK,aAAaP,aAAaQ,QAAQ,EAAE;QAC7D,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,OAAOR,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,OAAOC,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIQ,QAAQ,SAACC,SAASC;eAC3Bf,OAAOC,SAASC,MAAMC,cAAcC,SAAS,SAACY,KAAKC;YACjDD,MAAMD,OAAOC,OAAOF,QAAQG;QAC9B;;AAEJ"}
@@ -207,9 +207,7 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
207
207
  'finish'
208
208
  ]));
209
209
  }
210
- queue.defer(_crossspawncb.default.worker.bind(null, cp, _object_spread_props(_object_spread({}, csOptions), {
211
- encoding: 'utf8'
212
- })));
210
+ queue.defer(_crossspawncb.default.worker.bind(null, cp, csOptions));
213
211
  queue.await(function(err) {
214
212
  var res = err ? err : {};
215
213
  res.stdout = outputs.stdout ? outputs.stdout.output : null;
@@ -225,7 +223,6 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
225
223
  store.updateProcess(_object_spread_props(_object_spread({}, item), {
226
224
  state: err ? 'error' : 'success'
227
225
  }));
228
- // ensure rendering completes
229
226
  terminal.release(function() {
230
227
  err ? callback(err) : callback(null, res);
231
228
  });
@@ -260,9 +257,7 @@ function spawnTerminal(command, args, spawnOptions, options, callback) {
260
257
  'finish'
261
258
  ]));
262
259
  }
263
- queue.defer(_crossspawncb.default.worker.bind(null, cp, _object_spread_props(_object_spread({}, csOptions), {
264
- encoding: encoding || 'utf8'
265
- })));
260
+ queue.defer(_crossspawncb.default.worker.bind(null, cp, csOptions));
266
261
  queue.await(function(err) {
267
262
  var res = err ? err : {};
268
263
  res.stdout = outputs.stdout ? outputs.stdout.output : null;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.ts';\nimport addLines from './lib/addLines.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.ts';\nimport { LineType } from './types.ts';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: encoding || 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawnTerminal","terminal","createApp","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","crypto","randomUUID","addProcess","title","concat","formatArguments","join","state","lines","cp","crossSpawn","outputs","stdout","stderr","queue","Queue","addLines","item","processes","find","x","updateProcess","map","text","type","LineType","defer","oo","bind","pipe","spawn","worker","await","err","res","output","release","concatWritable","toString"],"mappings":";;;;+BAeA;;;eAAwBA;;;oEAf4B;6DACjC;4DACJ;8DACG;kEAEI;iEACD;uEACM;wEACC;uBAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,WAAWC,IAAAA,oBAAS;AAEX,SAASF,cAAcG,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,IAAQC,WAAkCH,aAAlCG,UAAUC,QAAwBJ,aAAxBI,OAAUC,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,SAACC;YACf,IAAMC,KAAKC,eAAM,CAACC,UAAU;YAC5BH,MAAMI,UAAU,CAAC;gBAAEH,IAAAA;gBAAII,OAAO;oBAACd;iBAAQ,CAACe,MAAM,CAACC,IAAAA,0BAAe,EAACf,OAAOgB,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKhB;YAEjH,IAAMiB,KAAKC,IAAAA,wBAAU,EAACrB,SAASC,MAAMM;YACrC,IAAMe,UAAU;gBAAEC,QAAQ;gBAAMC,QAAQ;YAAK;YAE7C,IAAMC,QAAQ,IAAIC,gBAAK;YACvB,IAAIN,GAAGG,MAAM,EAAE;gBACbD,QAAQC,MAAM,GAA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gBAAS;aAAS;QAC/F;QACAC,MAAMY,KAAK,CAACI,qBAAK,CAACC,MAAM,CAACH,IAAI,CAAC,MAAMnB,IAAI,wCAAKb;YAAWF,UAAUA,YAAY;;QAC9EoB,MAAMkB,KAAK,CAAC,SAACC;YACX,IAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAItB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACuB,MAAM,GAAG;YACtDD,IAAIrB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACsB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAItB,MAAM;gBAAEsB,IAAIrB,MAAM;gBAAE;aAAK;YAC3CoB,MAAMxC,SAASwC,OAAOxC,SAAS,MAAMyC;QACvC;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.ts';\nimport addLines from './lib/addLines.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.ts';\nimport { LineType } from './types.ts';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawnTerminal","terminal","createApp","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","crypto","randomUUID","addProcess","title","concat","formatArguments","join","state","lines","cp","crossSpawn","outputs","stdout","stderr","queue","Queue","addLines","item","processes","find","x","updateProcess","map","text","type","LineType","defer","oo","bind","pipe","spawn","worker","await","err","res","output","release","concatWritable","toString"],"mappings":";;;;+BAeA;;;eAAwBA;;;oEAf4B;6DACjC;4DACJ;8DACG;kEAEI;iEACD;uEACM;wEACC;uBAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,WAAWC,IAAAA,oBAAS;AAEX,SAASF,cAAcG,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,IAAQC,WAAkCH,aAAlCG,UAAUC,QAAwBJ,aAAxBI,OAAUC,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,SAACC;YACf,IAAMC,KAAKC,eAAM,CAACC,UAAU;YAC5BH,MAAMI,UAAU,CAAC;gBAAEH,IAAAA;gBAAII,OAAO;oBAACd;iBAAQ,CAACe,MAAM,CAACC,IAAAA,0BAAe,EAACf,OAAOgB,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKhB;YAEjH,IAAMiB,KAAKC,IAAAA,wBAAU,EAACrB,SAASC,MAAMM;YACrC,IAAMe,UAAU;gBAAEC,QAAQ;gBAAMC,QAAQ;YAAK;YAE7C,IAAMC,QAAQ,IAAIC,gBAAK;YACvB,IAAIN,GAAGG,MAAM,EAAE;gBACbD,QAAQC,MAAM,GAAGI,IAAAA,mBAAQ,EAAC,SAACR;oBACzB,IAAMS,OAAOnB,MAAMoB,SAAS,CAACC,IAAI,CAAC,SAACC;+BAAMA,EAAErB,EAAE,KAAKA;;oBAClDD,MAA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C1BC,IAAItB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACuB,MAAM,GAAG;YACtDD,IAAIrB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACsB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAItB,MAAM;gBAAEsB,IAAIrB,MAAM;gBAAE;aAAK;YAC3CoB,MAAMxC,SAASwC,OAAOxC,SAAS,MAAMyC;QACvC;IACF;AACF"}
@@ -3,4 +3,4 @@ export { default as formatArguments } from './lib/formatArguments.js';
3
3
  export * from './types.js';
4
4
  const major = +process.versions.node.split('.')[0];
5
5
  import { default as spawnTerminal } from './spawnTerminal.js';
6
- export default major > 14 ? spawnTerminal : undefined;
6
+ export default major > 18 ? spawnTerminal : undefined;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["export { default as figures } from './lib/figures.ts';\nexport { default as formatArguments } from './lib/formatArguments.ts';\nexport * from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\n\nimport { default as spawnTerminal } from './spawnTerminal.ts';\nexport default major > 14 ? spawnTerminal : (undefined as typeof spawnTerminal);\n"],"names":["default","figures","formatArguments","major","process","versions","node","split","spawnTerminal","undefined"],"mappings":"AAAA,SAASA,WAAWC,OAAO,QAAQ,mBAAmB;AACtD,SAASD,WAAWE,eAAe,QAAQ,2BAA2B;AACtE,cAAc,aAAa;AAE3B,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,SAASP,WAAWQ,aAAa,QAAQ,qBAAqB;AAC9D,eAAeL,QAAQ,KAAKK,gBAAiBC,UAAmC"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/index-esm.ts"],"sourcesContent":["export { default as figures } from './lib/figures.ts';\nexport { default as formatArguments } from './lib/formatArguments.ts';\nexport * from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\n\nimport { default as spawnTerminal } from './spawnTerminal.ts';\nexport default major > 18 ? spawnTerminal : (undefined as typeof spawnTerminal);\n"],"names":["default","figures","formatArguments","major","process","versions","node","split","spawnTerminal","undefined"],"mappings":"AAAA,SAASA,WAAWC,OAAO,QAAQ,mBAAmB;AACtD,SAASD,WAAWE,eAAe,QAAQ,2BAA2B;AACtE,cAAc,aAAa;AAE3B,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,SAASP,WAAWQ,aAAa,QAAQ,qBAAqB;AAC9D,eAAeL,QAAQ,KAAKK,gBAAiBC,UAAmC"}
@@ -4,6 +4,9 @@ function worker(command, args, spawnOptions, options, callback) {
4
4
  }).catch(callback);
5
5
  }
6
6
  export default function spawnTerminal(command, args, spawnOptions, options, callback) {
7
+ if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) {
8
+ throw new Error("Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output.");
9
+ }
7
10
  if (typeof options === 'function') {
8
11
  callback = options;
9
12
  options = {};
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/spawnTerminal.ts"],"sourcesContent":["import type { SpawnOptions, SpawnResult, TerminalCallback, TerminalOptions } from './types.ts';\n\nfunction worker(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n import('./worker.js')\n .then((fn) => {\n fn.default(command, args, spawnOptions, options, callback);\n })\n .catch(callback);\n}\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | TerminalCallback, callback?: TerminalCallback): undefined | Promise<SpawnResult> {\n if (typeof options === 'function') {\n callback = options as TerminalCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback as TerminalCallback);\n return new Promise((resolve, reject) =>\n worker(command, args, spawnOptions, options, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n}\n"],"names":["worker","command","args","spawnOptions","options","callback","then","fn","default","catch","spawnTerminal","Promise","resolve","reject","err","result"],"mappings":"AAEA,SAASA,OAAOC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IAC/H,MAAM,CAAC,eACJC,IAAI,CAAC,CAACC;QACLA,GAAGC,OAAO,CAACP,SAASC,MAAMC,cAAcC,SAASC;IACnD,GACCI,KAAK,CAACJ;AACX;AAEA,eAAe,SAASK,cAAcT,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA4C,EAAEC,QAA2B;IAC1K,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,OAAOC,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIM,QAAQ,CAACC,SAASC,SAC3Bb,OAAOC,SAASC,MAAMC,cAAcC,SAAS,CAACU,KAAKC;YACjDD,MAAMD,OAAOC,OAAOF,QAAQG;QAC9B;AAEJ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/spawnTerminal.ts"],"sourcesContent":["import type { SpawnOptions, SpawnResult, TerminalCallback, TerminalOptions } from './types.ts';\n\nfunction worker(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n import('./worker.js')\n .then((fn) => {\n fn.default(command, args, spawnOptions, options, callback);\n })\n .catch(callback);\n}\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options?: TerminalOptions | TerminalCallback, callback?: TerminalCallback): undefined | Promise<SpawnResult> {\n if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) {\n throw new Error(\"Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output.\");\n }\n\n if (typeof options === 'function') {\n callback = options as TerminalCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback as TerminalCallback);\n return new Promise((resolve, reject) =>\n worker(command, args, spawnOptions, options, (err, result) => {\n err ? reject(err) : resolve(result);\n })\n );\n}\n"],"names":["worker","command","args","spawnOptions","options","callback","then","fn","default","catch","spawnTerminal","stdio","encoding","Error","Promise","resolve","reject","err","result"],"mappings":"AAEA,SAASA,OAAOC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IAC/H,MAAM,CAAC,eACJC,IAAI,CAAC,CAACC;QACLA,GAAGC,OAAO,CAACP,SAASC,MAAMC,cAAcC,SAASC;IACnD,GACCI,KAAK,CAACJ;AACX;AAEA,eAAe,SAASK,cAAcT,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA4C,EAAEC,QAA2B;IAC1K,IAAIF,aAAaQ,KAAK,KAAK,aAAaR,aAAaS,QAAQ,EAAE;QAC7D,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,OAAOT,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,OAAOC,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIS,QAAQ,CAACC,SAASC,SAC3BhB,OAAOC,SAASC,MAAMC,cAAcC,SAAS,CAACa,KAAKC;YACjDD,MAAMD,OAAOC,OAAOF,QAAQG;QAC9B;AAEJ"}
@@ -143,9 +143,7 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
143
143
  'finish'
144
144
  ]));
145
145
  }
146
- queue.defer(spawn.worker.bind(null, cp, _object_spread_props(_object_spread({}, csOptions), {
147
- encoding: 'utf8'
148
- })));
146
+ queue.defer(spawn.worker.bind(null, cp, csOptions));
149
147
  queue.await((err)=>{
150
148
  const res = err ? err : {};
151
149
  res.stdout = outputs.stdout ? outputs.stdout.output : null;
@@ -159,7 +157,6 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
159
157
  store.updateProcess(_object_spread_props(_object_spread({}, item), {
160
158
  state: err ? 'error' : 'success'
161
159
  }));
162
- // ensure rendering completes
163
160
  terminal.release(()=>{
164
161
  err ? callback(err) : callback(null, res);
165
162
  });
@@ -194,9 +191,7 @@ export default function spawnTerminal(command, args, spawnOptions, options, call
194
191
  'finish'
195
192
  ]));
196
193
  }
197
- queue.defer(spawn.worker.bind(null, cp, _object_spread_props(_object_spread({}, csOptions), {
198
- encoding: encoding || 'utf8'
199
- })));
194
+ queue.defer(spawn.worker.bind(null, cp, csOptions));
200
195
  queue.await((err)=>{
201
196
  const res = err ? err : {};
202
197
  res.stdout = outputs.stdout ? outputs.stdout.output : null;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.ts';\nimport addLines from './lib/addLines.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.ts';\nimport { LineType } from './types.ts';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n // ensure rendering completes\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: encoding || 'utf8' }));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawn","crossSpawn","crypto","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","randomUUID","addProcess","title","concat","join","state","lines","cp","outputs","stdout","stderr","queue","item","processes","find","x","updateProcess","map","text","type","defer","bind","pipe","worker","await","err","res","output","release","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,eAAe,iBAAiB;AACvC,OAAOC,cAAc,oBAAoB;AACzC,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,qBAAqB,2BAA2B;AAGvD,SAASC,QAAQ,QAAQ,aAAa;AAEtC,MAAMC,WAAWL;AAEjB,eAAe,SAASM,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAgB,GAAGJ,cAAdK,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,CAACC;YACf,MAAMC,KAAKpB,OAAOqB,UAAU;YAC5BF,MAAMG,UAAU,CAAC;gBAAEF;gBAAIG,OAAO;oBAACb;iBAAQ,CAACc,MAAM,CAAClB,gBAAgBK,OAAOc,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKd;YAEjH,MAAMe,KAAK7B,WAAWW,SAASC,MAAMM;YACrC,MAAMY,UAAU;gBAAEC,QAAQ;gBAAMC,QAAQ;YAAK;YAE7C,MAAMC,QAAQ,I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,MAAM,CAACF,IAAI,CAAC,MAAMd,IAAI,wCAAKX;YAAWF,UAAUA,YAAY;;QAC9EiB,MAAMa,KAAK,CAAC,CAACC;YACX,MAAMC,MAAOD,MAAMA,MAAM,CAAC;YAC1BC,IAAIjB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACkB,MAAM,GAAG;YACtDD,IAAIhB,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACiB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAIjB,MAAM;gBAAEiB,IAAIhB,MAAM;gBAAE;aAAK;YAC3Ce,MAAMhC,SAASgC,OAAOhC,SAAS,MAAMiC;QACvC;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport createApp from './createApp.ts';\nimport addLines from './lib/addLines.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\n\nimport type { SpawnError, SpawnOptions, TerminalCallback, TerminalOptions } from './types.ts';\nimport { LineType } from './types.ts';\n\nconst terminal = createApp();\n\nexport default function spawnTerminal(command: string, args: string[], spawnOptions: SpawnOptions, options: TerminalOptions, callback: TerminalCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n terminal.retain((store) => {\n const id = crypto.randomUUID();\n store.addProcess({ id, title: [command].concat(formatArguments(args)).join(' '), state: 'running', lines: [], ...options });\n\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stdout, text }))) });\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = addLines((lines) => {\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, lines: item.lines.concat(lines.map((text) => ({ type: LineType.stderr, text }))) });\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n const item = store.processes.find((x) => x.id === id);\n store.updateProcess({ ...item, state: err ? 'error' : 'success' });\n\n terminal.release(() => {\n err ? callback(err) : callback(null, res);\n });\n });\n });\n } else {\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null, stderr: null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n}\n"],"names":["spawn","crossSpawn","crypto","oo","Queue","createApp","addLines","concatWritable","formatArguments","LineType","terminal","spawnTerminal","command","args","spawnOptions","options","callback","encoding","stdio","csOptions","retain","store","id","randomUUID","addProcess","title","concat","join","state","lines","cp","outputs","stdout","stderr","queue","item","processes","find","x","updateProcess","map","text","type","defer","bind","pipe","worker","await","err","res","output","release","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,eAAe,iBAAiB;AACvC,OAAOC,cAAc,oBAAoB;AACzC,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,qBAAqB,2BAA2B;AAGvD,SAASC,QAAQ,QAAQ,aAAa;AAEtC,MAAMC,WAAWL;AAEjB,eAAe,SAASM,cAAcC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAwB,EAAEC,QAA0B;IACrJ,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAgB,GAAGJ,cAAdK,uCAAcL;QAAlCG;QAAUC;;IAElB,IAAIA,UAAU,WAAW;QACvBR,SAASU,MAAM,CAAC,CAACC;YACf,MAAMC,KAAKpB,OAAOqB,UAAU;YAC5BF,MAAMG,UAAU,CAAC;gBAAEF;gBAAIG,OAAO;oBAACb;iBAAQ,CAACc,MAAM,CAAClB,gBAAgBK,OAAOc,IAAI,CAAC;gBAAMC,OAAO;gBAAWC,OAAO,EAAE;eAAKd;YAEjH,MAAMe,KAAK7B,WAAWW,SAASC,MAAMM;YACrC,MAAMY,UAAU;gBAAEC,QAAQ;gBAAMC,QAAQ;YAAK;YAE7C,MAAMC,QAAQ,IAAI9B;YAClB,IAAI0B,GAAGE,MAAM,EAAE;gBACbD,QAAQC,MAAM,GAAG1B,SAAS,CAACuB;oBACzB,MAAMM,OAAOd,MAAMe,SAAS,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEhB,EAAE,KAAKA;oBAClD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AGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAACiB,MAAM,GAAG;YACtDD,IAAIC,MAAM,GAAG;gBAACD,IAAIjB,MAAM;gBAAEiB,IAAIhB,MAAM;gBAAE;aAAK;YAC3Ce,MAAMhC,SAASgC,OAAOhC,SAAS,MAAMiC;QACvC;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spawn-term",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Formats spawn with for terminal grouping",
5
5
  "keywords": [
6
6
  "spawn",
@@ -35,6 +35,7 @@
35
35
  "scripts": {
36
36
  "build": "tsds build",
37
37
  "format": "biome check --write --unsafe",
38
+ "prepublishOnly": "tsds validate",
38
39
  "test": "mocha --no-timeouts test/**/*.test.*",
39
40
  "test:engines": "nvu engines tsds test:node --no-timeouts",
40
41
  "version": "tsds version"