first commit

This commit is contained in:
2026-09-08 20:28:54 +08:00
commit 2ada8d3d5a
37380 changed files with 4886169 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
export declare const ADB_BINARY_FILE: {
[key: string]: string;
};
export declare function isSystemAdbAvailable(): boolean;
export declare function execADBCommand(command: string, option?: object): Promise<any>;
+36
View File
@@ -0,0 +1,36 @@
"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;