|
|
"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;
|
|
|
}
|
|
|
|
|
|
var _debug = _interopRequireDefault(require("./debug"));
|
|
|
|
|
|
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) {
|
|
|
var _lstatSync, _lstatSync$isSymbolic;
|
|
|
|
|
|
// 没有 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'];
|
|
|
}
|
|
|
|
|
|
return ['tyarn', 'yarn'];
|
|
|
} // 依赖是 link 文件
|
|
|
|
|
|
|
|
|
const depDir = (0, _path().join)(cwd, 'node_modules', deps[0]);
|
|
|
(0, _debug.default)('depDir', depDir, deps);
|
|
|
const isDepSymLink = (_lstatSync = (0, _fs().lstatSync)(depDir)) === null || _lstatSync === void 0 ? void 0 : (_lstatSync$isSymbolic = _lstatSync.isSymbolicLink) === null || _lstatSync$isSymbolic === void 0 ? void 0 : _lstatSync$isSymbolic.call(_lstatSync);
|
|
|
|
|
|
if (isDepSymLink) {
|
|
|
if (process.env.BIGFISH_COMPAT) {
|
|
|
return ['tnpm'];
|
|
|
}
|
|
|
|
|
|
return ['tnpm', 'cnpm', 'pnpm'];
|
|
|
} // 检测不到。
|
|
|
|
|
|
|
|
|
return [];
|
|
|
} |