23 lines
822 B
JavaScript
23 lines
822 B
JavaScript
|
|
#!/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);
|
|||
|
|
}
|