"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _default; function _react() { const data = _interopRequireDefault(require("react")); _react = function _react() { return data; }; return data; } function _path() { const data = require("path"); _path = function _path() { return data; }; return data; } function _fs() { const data = require("fs"); _fs = function _fs() { return data; }; return data; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function haveFile(cwd, file) { return (0, _fs().existsSync)((0, _path().join)(cwd, file)); } function _default(cwd) { // 没有 package.json 或 node_modules,判断不出。 if (!haveFile(cwd, 'package.json') || !haveFile(cwd, 'node_modules')) { return []; } const pkg = JSON.parse((0, _fs().readFileSync)((0, _path().join)(cwd, 'package.json'), 'utf-8')); const deps = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})]; // 没有依赖,判断不出。 if (!deps.length) { return []; } // 有 package-lock.json if (haveFile(cwd, 'package-lock.json')) { return ['npm']; } // 有 yarn.lock if (haveFile(cwd, 'yarn.lock') && haveFile(cwd, 'node_modules/.yarn-integrity')) { const isAliRegistry = (0, _fs().readFileSync)((0, _path().join)(cwd, 'node_modules/.yarn-integrity'), 'utf-8').includes('registry.npm.alibaba-inc.com'); if (isAliRegistry) { return ['ayarn', 'yarn']; } else { return ['tyarn', 'yarn']; } } // 依赖是 link 文件 const depDir = (0, _path().join)(cwd, 'node_modules', deps[0]); const isDepSymLink = (0, _fs().lstatSync)(depDir).isSymbolicLink(); if (isDepSymLink) { if (process.env.BIGFISH_COMPAT) { return ['tnpm']; } else { return ['tnpm', 'cnpm', 'pnpm']; } } // 检测不到。 return []; }