"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const os = require("os"); const debug_1 = require("debug"); exports.log = (...args) => { // @ts-ignore return debug_1.default('umi-editor')(...args); }; exports.getOS = () => { if (typeof process === 'undefined') { return undefined; } if (process.platform === 'win32') return 'windows'; if (process.platform === 'darwin') return 'osx'; if (process.platform === 'linux') return 'linux'; return undefined; }; // Assume WSL / "Bash on Ubuntu on Windows" is being used, and // that the file exists on the Windows file system. // `os.release()` is "4.4.0-43-Microsoft" in the current release // build of WSL, see: https://github.com/Microsoft/BashOnWindows/issues/423#issuecomment-221627364 // When a Windows editor is specified, interop functionality can // handle the path translation, but only if a relative path is used. exports.isWSL = (fileName) => exports.getOS() === 'linux' && fileName.startsWith('/mnt/') && /Microsft/i.test(os.release()); exports.parseFile = (file) => { const fileName = file.replace(/:(\d+)(:(\d+))?/g, ''); const match = file.match(/:(\d+)(:(\d+))?/); const lineNumber = match && match[1]; const colNumber = match && match[3]; return { fileName, lineNumber: lineNumber || '', colNumber: colNumber || '', }; };