YZProjectCloud/yanzhu-ui-vue3/scripts/check-yarn.js

23 lines
822 B
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const packageManager = process.env.npm_config_user_agent || '';
const isYarn = packageManager.includes('yarn');
const isPnP = fs.existsSync(__dirname + '/../.pnp.cjs');
if (!isYarn && isPnP) {
console.log('\x1b[33m%s\x1b[0m', '⚠️ 警告:此项目使用 Yarn 4 PnP 模式');
console.log('\x1b[33m%s\x1b[0m', '⚠️ 请使用 yarn 命令而不是 npm');
console.log('\x1b[36m%s\x1b[0m', '✓ 推荐命令yarn dev');
console.log('\x1b[36m%s\x1b[0m', '✓ 安装依赖yarn install');
console.log('\x1b[36m%s\x1b[0m', '✓ 添加依赖yarn add <package>');
console.log('');
process.exit(1);
}