From 5d0dc2514fc6c129d9389f7c4e6b642ecc8d3cc7 Mon Sep 17 00:00:00 2001 From: Todd Brown Date: Mon, 20 Jan 2020 02:37:49 -0600 Subject: [PATCH] Fix docker in wsl2 When running the new experimental docker for desktop (Windows) in WSL2 open assumes that is has access to windows .exe files, which does not work in the context of docker. This uses the is-docker lib to revert to linux behavior in this case but still run things correctly if you're using WSL 1 or 2 outside of docker. --- index.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index daa32b7..5d24bc7 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const path = require('path'); const childProcess = require('child_process'); const fs = require('fs'); const isWsl = require('is-wsl'); +const isDocker = require('is-docker'); const pAccess = promisify(fs.access); const pExecFile = promisify(childProcess.execFile); @@ -61,7 +62,7 @@ module.exports = async (target, options) => { if (options.app) { cliArguments.push('-a', options.app); } - } else if (process.platform === 'win32' || isWsl) { + } else if (process.platform === 'win32' || (isWsl && !isDocker)) { command = 'cmd' + (isWsl ? '.exe' : ''); cliArguments.push('/s', '/c', 'start', '""', '/b'); diff --git a/package.json b/package.json index b06908f..3df6ae6 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "file" ], "dependencies": { + "is-docker": "^2.0.0", "is-wsl": "^2.1.0" }, "devDependencies": {