@livedesk/client 0.1.136 → 0.1.138

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