UNPKG

eisd

Version:

Execute your favorite command in SubDirectories. Use it like: `eisd '[command]' [subdirs...]` (Example: `eisd 'yarn build' client server scripts`)

30 lines (29 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getYarnWorkspaces = exports.checkYarnAvailability = void 0; const sh = require("shelljs"); function checkYarnAvailability() { if (!sh.which("yarn")) { throw new Error("Sorry, this script requires Yarn!"); } } exports.checkYarnAvailability = checkYarnAvailability; function getYarnWorkspaces() { const result = sh.exec("yarn workspaces info --json", { silent: true }); if (result.stderr) { throw new Error("Yarn workspaces not found!"); } try { const response = JSON.parse(result.stdout); const workspaces = JSON.parse(response.data); const workspacePaths = []; for (const iterator in workspaces) { workspacePaths.push(workspaces[iterator].location); } return workspacePaths; } catch (_a) { throw new Error("Something went wrong when trying to retrieve the yarn workspaces!"); } } exports.getYarnWorkspaces = getYarnWorkspaces;