UNPKG

@smj0x/homebridge-shortcuts-buttons

Version:

Run any Apple Shortcut with just the tap of a button, and execute a custom unix command (or another shortcut!) after completion to handle its success/failure, using x-callback-url.

24 lines 852 B
import { exec } from 'child_process'; import { promisify } from 'util'; const EXEC_DEFAULT_TIMEOUT = 5000; export class HSBUtils { log; constructor(log) { this.log = log; } async execAsync(command, options) { this.log.debug(`${this.constructor.name}::${this.execAsync.name} Executing`, command); const { stdout, stderr } = await promisify(exec).call(null, command, { timeout: EXEC_DEFAULT_TIMEOUT, ...options, }); if (HSBUtils.isNonEmptyString(stdout.toString())) { this.log.debug(stdout.toString()); } if (HSBUtils.isNonEmptyString(stderr.toString())) { this.log.error(stderr.toString()); } } static isNonEmptyString = (value) => typeof value === 'string' && value.trim() !== ''; } //# sourceMappingURL=utils.js.map