UNPKG

a2r

Version:
30 lines (29 loc) 1.2 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const fs_1 = require("@a2r/fs"); const getProjectPath_1 = __importDefault(require("./getProjectPath")); let frameworkPath = ''; const getFrameworkPath = async () => { if (!frameworkPath) { const projectPath = await (0, getProjectPath_1.default)(); const modulePackageJson = path_1.default.join(projectPath, 'node_modules', 'a2r', 'package.json'); const existsPackageJson = await (0, fs_1.exists)(modulePackageJson); if (existsPackageJson) { frameworkPath = path_1.default.dirname(modulePackageJson); } } if (!frameworkPath) { const parts = __dirname.split(path_1.default.sep); for (let i = parts.length - 1; i >= 0 && !frameworkPath; i -= 1) { if (parts[i] === 'a2r') { frameworkPath = parts.slice(0, i + 1).join(path_1.default.sep); } } } return frameworkPath; }; exports.default = getFrameworkPath;