UNPKG

datamax-cli

Version:

datamax plugin cli

46 lines (41 loc) 1.36 kB
const shelljs = require("shelljs"); const fs = require("fs-extra"); const path = require("path"); const chalk = require("chalk"); function openfront() { shelljs.exec("npm run serve", { async: true }); console.log(chalk.green("[+]打开插件预览成功")); } function openserve() { //打开脚手架服务 var datamaxUrl = shelljs.exec("npm root -g").stdout; datamaxUrl = datamaxUrl.slice(0, datamaxUrl.length - 1); let dxserveUrl = datamaxUrl + "/datamax-cli/assets/dxserve"; ///node_modules/.bin/nodemon /datamax-cli/assets/dxserve/bin/run"; //require('runkoa')(current_path + '/bin/www' ) // let execute = `${dxserveUrl}/node_modules/.bin/nodemon ${dxserveUrl}/bin/run`; let execute = `node ${dxserveUrl}/bin/run`; shelljs.exec(`${execute}`, { async: true }); console.log(chalk.green("[+]打开插件服务成功")); } module.exports = function (config, root, args) { var fstat; var source = process.cwd(); try { fstat = fs.statSync(source); } catch (e) { console.log(chalk.red(`source not found`)); return process.exit(); } if (fstat.isDirectory()) { var configUrl = path.join(source, "/package.json"); try { fstat = fs.statSync(configUrl); } catch (e) { console.log(chalk.red(`package.json not found`)); return process.exit(); } } openfront(); openserve(); };