UNPKG

builder-isv

Version:

ISV 模块本地预览与云构建器

53 lines (45 loc) 1.32 kB
/** * @author 龙喜<xiaolong.lxl@alibaba-inc.com> * @description Project */ 'use strict'; const path = require('path'); const Base = require('./base'); const Debug = require('debug'); const debug = Debug('builder:project'); module.exports = class Project extends Base { /** * 项目信息 * @param workSpace 工作空间 * @param invokeType 调用类型 preview | build */ constructor(workSpace, invokeType) { super(workSpace, invokeType); this.projectName = path.basename(this.workSpace); } /** * 获取项目信息 */ get projectInfo() { if (!this.__projectInfo) { this.__projectInfo = this.utils.JSONStore.create({}); try { this.__projectInfo.abcInfo = this.utils.JSONStore.create(path.join(this.workSpace, 'abc.json')); } catch (e) { throw { message: '获取项目信息失败:abc.json 解析失败:' + e.message }; } if (this.invokeType === Base.INVOKE_TYPE_PREVIEW) { try { this.__projectInfo.lightInfo = this.utils.JSONStore.create(path.join(this.workSpace, 'light.json')); } catch (e) { throw { message: '获取项目信息失败:light.json 解析失败' + e.message }; } } } return this.__projectInfo; } };