<ul dir="auto">
<li><strong>Electron Version:</strong><br>
8.0.0</li>
<li><strong>Operating System:</strong><br>
Windows 10</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>

</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">In most cases, desktopCaptuerer has been working fine, with the expected source names including <code class="notranslate">Entire Screen</code> in a single-monitor setup and <code class="notranslate">Screen 1</code> and <code class="notranslate">Screen 2</code> when there are two.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">However, in certain two-monitor setups, the source names only include <code class="notranslate">Entire Screen</code> instead of the expected <code class="notranslate">Screen 1</code> and <code class="notranslate">Screen 2</code>. So desktopCapturer is only able to record one of the screens. I am not sure what differentiates these setups from others. OS is Windows 10 across the board.</p>
<h3 dir="auto">To Reproduce</h3>




<h3 dir="auto">Screenshots</h3>

<h3 dir="auto">Additional Information</h3>
<ul dir="auto">
<li>Electron version: 1.7.10</li>
<li>Operating system: Mac 10.13.1</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">可以启动adb service通过<code class="notranslate">adb devices</code> 获取到设备id</p>

<h3 dir="auto">Actual behavior</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
A JavaScript error occurred in the main process

Uncaught Exception:

Error : spawn ENOTDIR
"><pre class="notranslate"><span class="pl-v">A</span> <span class="pl-v">JavaScript</span> <span class="pl-s1">error</span> <span class="pl-s1">occurred</span> <span class="pl-k">in</span> <span class="pl-s1">the</span> <span class="pl-s1">main</span> <span class="pl-s1">process</span>

Uncaught <span class="pl-v">Exception</span>:

Error : <span class="pl-s1">spawn</span> <span class="pl-c1">ENOTDIR</span></pre></div>
<p dir="auto">adb放置在<code class="notranslate">resources/mac/adb</code>，代码写在src/index.js中，整体的目录结构如下：</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="resources // adb二进制文件
src //源代码
.babelrc
package.json"><pre class="notranslate"><code class="notranslate">resources // adb二进制文件
src //源代码
.babelrc
package.json
</code></pre></div>
<p dir="auto">代码：</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import os from 'os';
import path  from 'path';
import childProcess from 'child_process';
const spawn = childProcess.spawn;
const PLATFORM = {
  MAC: 'mac',
  WINDOWS: 'windows',
  UNKNOWN: 'unknown'
}
function fetchPlatform(){
  switch(os.platform()){
    case 'darwin':
        return PLATFORM.MAC;
      break;
    case 'win32':
        return PLATFORM.WINDOWS;
      break;
    default:
        return PLATFORM.UNKNOWN;
      break;
  }
}
const platform = fetchPlatform();
const rootDir = path.resolve(__dirname,'../');
const RESOURCES = path.resolve(rootDir,'resources')
const _adbPath = path.resolve(RESOURCES,platform);
function fetchAdbPath(){
  switch(platform){
    case PLATFORM.MAC:
        return path.resolve(_adbPath,'adb');
      break;
    case PLATFORM.WINDOWS:
        return path.resolve(_adbPath, 'adb.exe');
      break;
    default:
        return false;
      break;
  }
}
export function start_server(callback){
  let adbExecPath = fetchAdbPath();
  if (adbExecPath){
    let adb = spawn(adbExecPath,['start-server']);
    adb.stdout.on('data', function (data) {
      console.log('stdout: ' + data);
    });
    adb.stderr.on('data', function (data) {
      console.log('stderr: ' + data);
    });
    adb.on('exit', function (code) {
      typeof callback === 'function' &amp;&amp; callback(code);
    });
    adb.stdin.end();
  } else {
    throw new Error('Not Found Android Debug Bridge');
  }
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">os</span> <span class="pl-k">from</span> <span class="pl-s">'os'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">path</span>  <span class="pl-k">from</span> <span class="pl-s">'path'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">childProcess</span> <span class="pl-k">from</span> <span class="pl-s">'child_process'</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">spawn</span> <span class="pl-c1">=</span> <span class="pl-s1">childProcess</span><span class="pl-kos">.</span><span class="pl-c1">spawn</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-c1">PLATFORM</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">MAC</span>: <span class="pl-s">'mac'</span><span class="pl-kos">,</span>
  <span class="pl-c1">WINDOWS</span>: <span class="pl-s">'windows'</span><span class="pl-kos">,</span>
  <span class="pl-c1">UNKNOWN</span>: <span class="pl-s">'unknown'</span>
<span class="pl-kos">}</span>
<span class="pl-k">function</span> <span class="pl-en">fetchPlatform</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
  <span class="pl-k">switch</span><span class="pl-kos">(</span><span class="pl-s1">os</span><span class="pl-kos">.</span><span class="pl-en">platform</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
    <span class="pl-k">case</span> <span class="pl-s">'darwin'</span>:
        <span class="pl-k">return</span> <span class="pl-c1">PLATFORM</span><span class="pl-kos">.</span><span class="pl-c1">MAC</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
    <span class="pl-k">case</span> <span class="pl-s">'win32'</span>:
        <span class="pl-k">return</span> <span class="pl-c1">PLATFORM</span><span class="pl-kos">.</span><span class="pl-c1">WINDOWS</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
    <span class="pl-k">default</span>:
        <span class="pl-k">return</span> <span class="pl-c1">PLATFORM</span><span class="pl-kos">.</span><span class="pl-c1">UNKNOWN</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-k">const</span> <span class="pl-s1">platform</span> <span class="pl-c1">=</span> <span class="pl-en">fetchPlatform</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">rootDir</span> <span class="pl-c1">=</span> <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">__dirname</span><span class="pl-kos">,</span><span class="pl-s">'../'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-c1">RESOURCES</span> <span class="pl-c1">=</span> <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">rootDir</span><span class="pl-kos">,</span><span class="pl-s">'resources'</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-s1">_adbPath</span> <span class="pl-c1">=</span> <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-c1">RESOURCES</span><span class="pl-kos">,</span><span class="pl-s1">platform</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">function</span> <span class="pl-en">fetchAdbPath</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
  <span class="pl-k">switch</span><span class="pl-kos">(</span><span class="pl-s1">platform</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
    <span class="pl-k">case</span> <span class="pl-c1">PLATFORM</span><span class="pl-kos">.</span><span class="pl-c1">MAC</span>:
        <span class="pl-k">return</span> <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">_adbPath</span><span class="pl-kos">,</span><span class="pl-s">'adb'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
    <span class="pl-k">case</span> <span class="pl-c1">PLATFORM</span><span class="pl-kos">.</span><span class="pl-c1">WINDOWS</span>:
        <span class="pl-k">return</span> <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">_adbPath</span><span class="pl-kos">,</span> <span class="pl-s">'adb.exe'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
    <span class="pl-k">default</span>:
        <span class="pl-k">return</span> <span class="pl-c1">false</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">start_server</span><span class="pl-kos">(</span><span class="pl-s1">callback</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
  <span class="pl-k">let</span> <span class="pl-s1">adbExecPath</span> <span class="pl-c1">=</span> <span class="pl-en">fetchAdbPath</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">adbExecPath</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-s1">adb</span> <span class="pl-c1">=</span> <span class="pl-s1">spawn</span><span class="pl-kos">(</span><span class="pl-s1">adbExecPath</span><span class="pl-kos">,</span><span class="pl-kos">[</span><span class="pl-s">'start-server'</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">adb</span><span class="pl-kos">.</span><span class="pl-c1">stdout</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'data'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'stdout: '</span> <span class="pl-c1">+</span> <span class="pl-s1">data</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">adb</span><span class="pl-kos">.</span><span class="pl-c1">stderr</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'data'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'stderr: '</span> <span class="pl-c1">+</span> <span class="pl-s1">data</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">adb</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'exit'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">code</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">typeof</span> <span class="pl-s1">callback</span> <span class="pl-c1">===</span> <span class="pl-s">'function'</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">callback</span><span class="pl-kos">(</span><span class="pl-s1">code</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">adb</span><span class="pl-kos">.</span><span class="pl-c1">stdin</span><span class="pl-kos">.</span><span class="pl-en">end</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
    <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-v">Error</span><span class="pl-kos">(</span><span class="pl-s">'Not Found Android Debug Bridge'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>

<h3 dir="auto">How to reproduce</h3>
<p dir="auto">将上述代码做为一个npm包，假设叫<code class="notranslate">adb-test-a</code>，然后在electron工程里，<code class="notranslate">npm install adb-test-a</code>，调用<code class="notranslate">start_server</code>，必抛错误：<code class="notranslate">Error : spawn ENOTDIR</code>。</p>