@wgoo/cli
Version:
Wgoo Cli 是一个 React 组件库构建工具,通过 Wgoo Cli 可以快速搭建一套功能完备的 React 组件库。
38 lines (29 loc) • 734 B
JavaScript
const execa = require('execa');
const { consola } = require('./logger');
const { execSync } = require('child_process');
let hasYarnCache;
function hasYarn() {
if (hasYarnCache === undefined) {
try {
execSync('yarn --version', { stdio: 'ignore' });
hasYarnCache = true;
} catch (e) {
hasYarnCache = false;
}
}
return hasYarnCache;
}
async function installDependencies() {
consola.info('Install Dependencies\n');
try {
const manager = hasYarn() ? 'yarn' : 'npm';
await execa(manager, ['install', '--prod=false'], {
stdio: 'inherit',
});
console.log('');
} catch (err) {
console.log(err);
throw err;
}
}
module.exports = { hasYarn, installDependencies };