智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/95/95c4563fdc318cbabfdaf307530...

36 lines
1.2 KiB

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const child_process_1 = require("child_process");
const which = require("which");
const base = path.resolve(__dirname, '..', 'bin');
exports.ADB_BINARY_FILE = {
win32: path.resolve(base, 'window/adb.exe'),
darwin: path.resolve(base, 'mac/adb'),
linux: path.resolve(base, 'linux/adb'),
};
function isSystemAdbAvailable() {
return !!which.sync('adb', { nothrow: true });
}
exports.isSystemAdbAvailable = isSystemAdbAvailable;
let systemAdbExist = isSystemAdbAvailable();
function execADBCommand(command, option) {
let execCmd = command;
if (!systemAdbExist) {
let cmd = command.split(' ');
const binFile = exports.ADB_BINARY_FILE[process.platform];
cmd[0] = `"${binFile}"`;
execCmd = cmd.join(' ');
}
return new Promise((resolve, reject) => {
child_process_1.exec(execCmd, option || { stdio: 'inherit' }, (err, stdout, stderr) => {
if (err) {
reject(err);
}
resolve(stdout);
});
}).catch(err => {
return err;
});
}
exports.execADBCommand = execADBCommand;