简体   繁体   English

使用exec()在cmd行中的电子js上执行命令'ADB设备'

[英]Executing command 'ADB devices' on electron js in cmd line using exec()

I'm using electron js and I'm a bit newbie in it. 我正在使用电子js,但我有点新手。

As per my knowledge, we can use all npm package as we can use in nodejs . 据我所知,我们可以像在nodejs那样使用所有npm包。 So, I am using 'node-command-line' package in it. 因此,我在其中使用'node-command-line'包。

Now, when I'm building the code in mac using 'electron-builder' , commands like adb devices are working perfectly when I launch the application with npm start . 现在,当我使用'electron-builder'在mac中构建代码时,当我使用npm start应用程序时,诸如adb devices类的命令可以正常工作。 But after building it in mac its throwing me an error, saying adb devices command not found with the same process. 但是在Mac中构建它后,抛出一个错误,说用同一进程找不到adb devices命令。

PFB the code: PFB代码:

var cmd     = require('node-command-line'),Promise = require('bluebird');
function runSingleCommandWithoutWait() {
    let listener=cmd.run('adb devices');
    listener.then(function(value_listener){  
        //SOME FUNCTION
    });
   }

When i build-l , it works in linux but not build -m is not working in mac system. 当我build-l时,它可以在linux中工作,但是不能编译-m在mac系统中不能工作。 It shows adb devices command not found . 它显示adb devices command not found

This executes the command once I run it by default in /bin/sh . 一旦我在/bin/sh默认运行该命令,它将执行该命令。 The path of adb in both the system has been set similar as applicable to each. 两个系统中adb的路径均已设置为适用于每个系统的相似路径。

How I make the command run in mac? 如何使命令在Mac中运行? Any help would be much appreciated 任何帮助将非常感激

Have you considered using adbkit ? 您是否考虑过使用adbkit

From adbkit GitHub: 从adbkit GitHub:

adbkit is a pure Node.js client for the Android Debug Bridge server. adbkit是Android调试桥服务器的纯Node.js客户端。 It can be used either as a library in your own application, or simply as a convenient utility for playing with your device. 它既可以用作您自己的应用程序中的库,也可以用作与设备一起播放的便捷实用程序。

Most of the adb command line tool's functionality is supported (including pushing/pulling files, installing APKs and processing logs) 支持大多数adb命令行工具的功能(包括推/拉文件,安装APK和处理日志)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM