chore(cli): improve build tasks
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { join } from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import {
|
||||
lstatSync,
|
||||
existsSync,
|
||||
@@ -156,19 +155,4 @@ export function smartOutputFile(filePath: string, content: string) {
|
||||
outputFileSync(filePath, content);
|
||||
}
|
||||
|
||||
let hasYarnCache: boolean;
|
||||
|
||||
export function hasYarn() {
|
||||
if (hasYarnCache === undefined) {
|
||||
try {
|
||||
execSync('yarn --version', { stdio: 'ignore' });
|
||||
hasYarnCache = true;
|
||||
} catch (e) {
|
||||
hasYarnCache = false;
|
||||
}
|
||||
}
|
||||
|
||||
return hasYarnCache;
|
||||
}
|
||||
|
||||
export { getVantConfig };
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// @ts-ignore
|
||||
import execa from 'execa';
|
||||
import { consola } from './logger';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
let hasYarnCache: boolean;
|
||||
|
||||
export function hasYarn() {
|
||||
if (hasYarnCache === undefined) {
|
||||
try {
|
||||
execSync('yarn --version', { stdio: 'ignore' });
|
||||
hasYarnCache = true;
|
||||
} catch (e) {
|
||||
hasYarnCache = false;
|
||||
}
|
||||
}
|
||||
|
||||
return hasYarnCache;
|
||||
}
|
||||
|
||||
export 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user