UNPKG

vtex

Version:

The platform for e-commerce apps

29 lines (28 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAppRoot = exports.MANIFEST_FILE_NAME = void 0; const tslib_1 = require("tslib"); const fs_1 = require("fs"); const path_1 = tslib_1.__importDefault(require("path")); const utils_1 = require("../error/utils"); exports.MANIFEST_FILE_NAME = 'manifest.json'; exports.getAppRoot = () => { if (process.env.OCLIF_COMPILATION) { return ''; } const cwd = process.cwd(); const { root: rootDirName } = path_1.default.parse(cwd); const find = dir => { try { fs_1.accessSync(path_1.default.join(dir, exports.MANIFEST_FILE_NAME)); return dir; } catch (err) { if (dir === rootDirName) { throw utils_1.createFlowIssueError("Manifest file doesn't exist or is not readable. Please make sure you're in the app's directory or add a manifest.json file in the root folder of the app."); } return find(path_1.default.resolve(dir, '..')); } }; return find(cwd); };