feat: detect alternative package managers based on lockfile

If a package manager is not explicitly set in config.json or passed-in via argv/env, NodeBB will now check for the presence of alternative package managers' lockfiles and adjust the package manager to-be-used accordingly. If the standard npm lockfile exists, npm will always be used.
This commit is contained in:
Julian Lam
2022-02-02 12:46:13 -05:00
parent d134567dab
commit 8ba9e67cbd
3 changed files with 40 additions and 15 deletions

View File

@@ -13,10 +13,9 @@ const db = require('../database');
const meta = require('../meta');
const pubsub = require('../pubsub');
const { paths } = require('../constants');
const pkgInstall = require('../cli/package-install');
const supportedPackageManagerList = require('../cli/package-install').supportedPackageManager;
// load config from src/cli/package-install.js
const packageManager = supportedPackageManagerList.indexOf(nconf.get('package_manager')) >= 0 ? nconf.get('package_manager') : 'npm';
const packageManager = pkgInstall.getPackageManager();
let packageManagerExecutable = packageManager;
const packageManagerCommands = {
yarn: {