UNPKG

@ali-i18n-fe/dada-component

Version:
39 lines (30 loc) 1.91 kB
const { shellSyncExec, hasPreviewAtPath } = require("./utils"); const { isDef } = require("./utils/def"); const { log } = require("@ali-i18n-fe/lsc-utils"); module.exports = { hasInstall: false, async load() { if (!!hasPreviewAtPath()) { log.info("preview视图已经存在不需要安装环境"); return Promise.resolve(); } if (this.hasInstall) { return Promise.resolve(); } try { if (!isDef()) { throw new Error(); } shellSyncExec(` echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse \\n deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse \\n deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse \\n deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse \\n deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse \\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse \\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse \\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse \\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse \\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse ' > /etc/apt/sources.list apt-get update apt-get -y -q install gconf-service libgconf-2-4 libgtk-3-0 libxss1 fonts-liberation libappindicator1 lsb-release xdg-utils fonts-wqy-zenhei --fix-missing `); } catch (e) { log.info("当前环境不是Def环境,不需要安装依赖"); } shellSyncExec("tnpm i -g puppeteer@2.0.0"); shellSyncExec("tnpm link puppeteer"); this.hasInstall = true; return Promise.resolve(); } };