vtex
Version:
The platform for e-commerce apps
25 lines (24 loc) • 937 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const fs_1 = require("fs");
const path_1 = tslib_1.__importDefault(require("path"));
const error_1 = require("../error");
exports.MANIFEST_FILE_NAME = 'manifest.json';
exports.getAppRoot = () => {
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 (e) {
if (dir === rootDirName) {
throw new error_1.CommandError("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);
};