mirror of
https://github.com/appium/appium.git
synced 2026-02-20 18:30:11 -06:00
fix{support}: keep backward compatibility for https://github.com/appium/appium/pull/2078 (#20797)
This commit is contained in:
@@ -201,7 +201,17 @@ export class NPM {
|
||||
* @param {InstallPackageOpts} opts
|
||||
* @returns {Promise<NpmInstallReceipt>}
|
||||
*/
|
||||
async installPackage(cwd, installStr, {pkgName, installType}) {
|
||||
async installPackage(cwd, installStr, {pkgName, pkgVer, installType} = {}) {
|
||||
let _installStr = installStr;
|
||||
// FIXME: Please remove this '!pkgName' case after bumping major version of this support package.
|
||||
// This is a temporary workaround for backward compatibility related to https://github.com/appium/appium/pull/20788
|
||||
if (!pkgName) {
|
||||
// Old appium package passes an empty 'pkgName' as part of the option. Then,
|
||||
// we could consider it is for old argument case.
|
||||
pkgName = installStr;
|
||||
_installStr = pkgVer ? `${pkgName}@${pkgVer}` : pkgName;
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
let dummyPkgJson;
|
||||
const dummyPkgPath = path.join(cwd, 'package.json');
|
||||
@@ -225,7 +235,7 @@ export class NPM {
|
||||
}
|
||||
|
||||
const cmd = installType === 'local' ? 'link' : 'install';
|
||||
const res = await this.exec(cmd, [...installOpts, installStr], {
|
||||
const res = await this.exec(cmd, [...installOpts, _installStr], {
|
||||
cwd,
|
||||
json: true,
|
||||
lockFile: this._getInstallLockfilePath(cwd),
|
||||
@@ -287,8 +297,10 @@ export const npm = new NPM();
|
||||
/**
|
||||
* Options for {@link NPM.installPackage}
|
||||
* @typedef InstallPackageOpts
|
||||
* @property {string} pkgName - the name of the package to install
|
||||
* @property {string} [pkgName] - the name of the package to install. Used by appium package 2.12.2 and newer versions.
|
||||
* @property {import('type-fest').LiteralUnion<'local', string>} [installType] - whether to install from a local path or from npm
|
||||
* @property {string} [pkgVer] - The version of the package to install.
|
||||
* This is used for backward compatibility for this support package v5 with appium package 2.12.1 and lower versions.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user