async findPackage(dir) { // Find the nearest package.json file within the current node_modules folder let root = path.parse(dir).root; while (dir !== root && path.basename(dir) !== "node_modules") { try { return await this.readPackage(dir); } catch (err) { // ignore } dir = path.dirname(dir); } }
let root = path.parse(dir).root;
wordupConformPath(aPath) { if(process.platform === "win32"){ const root = path.parse(aPath).root return path.resolve("/", aPath.replace(root, "")) } return aPath; }
function diskname(path) { var parsed = Path.parse(Path.normalize(path)); var disk = parsed.root.split('\\')[0]; if (!isDiskname(disk)) { throw new Error('Bad path'); } return disk; }
function findCode() { let currentPath = process.cwd(); let searchedAll = false; do { const parsed = path.parse(currentPath); const codeDir = path.join(currentPath, codeDirName); const [codeFound, codePath] = searchCode(codeDir, ccodeBinName); if (codeFound) return [codeFound, codePath]; if (parsed.root === currentPath) searchedAll = true; else currentPath = path.normalize(`${currentPath}${path.sep}..`); } while (!searchedAll); return getCodeFromPathEnv(); }
static getFreeDiskSpace(location) { return Platform.identify({ win32: ()=> { let disk = path.parse(location).root.charAt(0); return pify(child_process.exec)(`powershell -command "& {(Get-WMIObject Win32_Logicaldisk -filter deviceid='''${disk}:''').FreeSpace;[Environment]::Exit(0);}"`).then((stdout) => { return Number.parseInt(stdout); }).catch(IGNORE); }, darwin: ()=> { let path = location[0] === '/' ? '/' + location.split('/')[1] : location.split('/')[0]; return pify(child_process.exec)(`df -k ${path}`).then((stdout) => { let lines = stdout.split('\n'); let split = lines[1].replace( / +/g, ' ' ).split(' '); return Number.parseInt(split[split.length - 1] === '/' ? split[3] : split[4]); }).catch(()=> 'No such file or dir'); }, default: ()=> Promise.resolve() }); }
function makeRelativeNormalizedPath(str, sep) { const parsed = parsePath(str); let root = parsed.root; let dir; let file = parsed.base;
async findPackage(dir) { // Find the nearest package.json file within the current node_modules folder let root = path.parse(dir).root; while (dir !== root && path.basename(dir) !== "node_modules") { try { return await this.readPackage(dir); } catch (err) { // ignore } dir = path.dirname(dir); } }
let root = path.parse(dir).root;
function makeRelativeNormalizedPath(str, sep) { const parsed = parsePath(str); let root = parsed.root; let dir; let file = parsed.base;