diff --git a/lib/constants.js b/lib/constants.js index 1ee861a..eec8e6f 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -16,8 +16,20 @@ const path = require ("path"); const os = require("os"); +const child_process = require('child_process'); -const home = os.homedir(); +let home = os.homedir(); +if (os.platform() === 'linux') { + try { + const username = child_process.execSync("powershell.exe '$env:UserName'").toString().trim(); + + if (username) { + home = '/mnt/c/Users/' + username + '/'; + } + } catch (e) { + // Not a WSL machine + } +} module.exports = { FOLDERS: { @@ -26,6 +38,11 @@ module.exports = { "p": path.join(home, "Library", "Application Support", "Adobe", "Adobe XD (Prerelease)"), "d": path.join(home, "Library", "Application Support", "Adobe", "Adobe XD (Dev)") }, + "wsl": { + "r": path.join(home, "AppData", "Local", "Packages", "Adobe.CC.XD_adky2gkssdxte", "LocalState"), + "p": path.join(home, "AppData", "Local", "Packages", "Adobe.CC.XD.Prerelease_adky2gkssdxte", "LocalState"), + "d": path.join(home, "AppData", "Local", "Packages", "Adobe.CC.XD.Dev_adky2gkssdxte", "LocalState") + }, "win": { "r": path.join(home, "AppData", "Local", "Packages", "Adobe.CC.XD_adky2gkssdxte", "LocalState"), "p": path.join(home, "AppData", "Local", "Packages", "Adobe.CC.XD.Prerelease_adky2gkssdxte", "LocalState"), diff --git a/lib/platform.js b/lib/platform.js index 534b5fc..0b1f5fe 100644 --- a/lib/platform.js +++ b/lib/platform.js @@ -15,8 +15,9 @@ */ const process = require("process"); +const os = require("os"); -let platform; +let platform = null; switch(process.platform) { case "darwin": platform = "mac"; @@ -24,6 +25,10 @@ switch(process.platform) { case "win32": platform = "win"; break; + case "linux": + if (os.release().toLowerCase().includes("microsoft")) + platform = "wsl"; + break; default: platform = null; }