UNPKG

goldpankit

Version:

GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。

29 lines (28 loc) 710 B
const { exec } = require('child_process'); const fs = require('../utils/fs') const log = require('../utils/log') module.exports = { /** * 执行node命令 * @param dir 执行目录 * @param command 命令 * * @returns {Promise<unknown>} */ exec (dir, command) { return new Promise((resolve, reject) => { const commands = command.split('\n') log.debug(`execute node command: ${commands.join(' && ')}`) exec(commands.join('&&'), {cwd: dir}, (err) => { if (err) { return reject(err) } return resolve() }) }) }, execFile (dir, filepath) { const content = fs.readFile(filepath) return this.exec(dir, content) } }