@livedesk/client 0.1.136 → 0.1.137

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.
@@ -1313,37 +1313,39 @@ function remotePolicyAllows(options, command) {
1313
1313
  function scheduleClientUpdate(options, payload = {}) {
1314
1314
  const parentPid = Number(process.env.LIVEDESK_CLIENT_PARENT_PID || process.ppid);
1315
1315
  if (!Number.isInteger(parentPid) || parentPid <= 1) {
1316
- throw new Error('LiveDesk client launcher process id is unavailable.');
1316
+ return Promise.reject(new Error('LiveDesk client launcher process id is unavailable.'));
1317
1317
  }
1318
1318
  const command = process.platform === 'win32' ? 'npx.cmd' : 'npx';
1319
- const child = spawn(command, [
1320
- '-y',
1321
- '--prefer-online',
1322
- 'livedesk@latest',
1323
- 'client',
1324
- '--no-login',
1325
- '--update-wait-pid',
1326
- String(parentPid)
1327
- ], {
1328
- env: {
1329
- ...process.env,
1330
- LIVEDESK_CLIENT_UPDATE_TARGET_VERSION: String(payload.targetVersion || process.env.LIVEDESK_CLIENT_UPDATE_TARGET_VERSION || '')
1331
- },
1332
- detached: true,
1333
- stdio: 'ignore',
1334
- windowsHide: true
1335
- });
1336
- child.once('error', error => {
1337
- console.error(`LiveDesk client updater failed to start: ${error.message}`);
1319
+ return new Promise((resolve, reject) => {
1320
+ const child = spawn(command, [
1321
+ '-y',
1322
+ '--prefer-online',
1323
+ 'livedesk@latest',
1324
+ 'client',
1325
+ '--no-login',
1326
+ '--update-wait-pid',
1327
+ String(parentPid)
1328
+ ], {
1329
+ env: {
1330
+ ...process.env,
1331
+ LIVEDESK_CLIENT_UPDATE_TARGET_VERSION: String(payload.targetVersion || process.env.LIVEDESK_CLIENT_UPDATE_TARGET_VERSION || '')
1332
+ },
1333
+ detached: true,
1334
+ stdio: 'ignore',
1335
+ windowsHide: true
1336
+ });
1337
+ child.once('error', reject);
1338
+ child.once('spawn', () => {
1339
+ child.unref();
1340
+ resolve({
1341
+ ok: true,
1342
+ status: 'update-scheduled',
1343
+ targetVersion: String(payload.targetVersion || ''),
1344
+ parentPid,
1345
+ restartAfterMs: 500
1346
+ });
1347
+ });
1338
1348
  });
1339
- child.unref();
1340
- return {
1341
- ok: true,
1342
- status: 'update-scheduled',
1343
- targetVersion: String(payload.targetVersion || ''),
1344
- parentPid,
1345
- restartAfterMs: 500
1346
- };
1347
1349
  }
1348
1350
 
1349
1351
  async function handleRemoteCommand(socket, options, message, nextFrameSeq, activeStreams) {
@@ -1373,7 +1375,7 @@ async function handleRemoteCommand(socket, options, message, nextFrameSeq, activ
1373
1375
 
1374
1376
  if (command === 'livedesk.client-update') {
1375
1377
  try {
1376
- const result = scheduleClientUpdate(options, message.payload || {});
1378
+ const result = await scheduleClientUpdate(options, message.payload || {});
1377
1379
  writeJsonLine(socket, {
1378
1380
  type: 'command.result',
1379
1381
  commandId: message.commandId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.136",
3
+ "version": "0.1.137",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {