Skip to content

Commit 8869a01

Browse files
zyy7259haoqunjiang
authored andcommitted
feat: support custom package manager (#4621)
Closes #4483 * feat: support custom package manager * feat: refine warning msg for unknown package manager * feat: refine blank lines * feat: refine warning msg for unknown package manager * feat: refine warning msg for unknown package manager
1 parent ed2b888 commit 8869a01

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/@vue/cli/lib/util/ProjectPackageManager.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const execa = require('execa')
55
const minimist = require('minimist')
66
const semver = require('semver')
77
const LRU = require('lru-cache')
8+
const chalk = require('chalk')
89

910
const {
1011
hasYarn,
@@ -13,6 +14,7 @@ const {
1314
hasProjectPnpm
1415
} = require('@vue/cli-shared-utils/lib/env')
1516
const { isOfficialPlugin, resolvePluginId } = require('@vue/cli-shared-utils/lib/pluginResolution')
17+
const { log, warn } = require('@vue/cli-shared-utils/lib/logger')
1618

1719
const { loadOptions } = require('../options')
1820
const getPackageJson = require('./getPackageJson')
@@ -76,7 +78,13 @@ class PackageManager {
7678
}
7779

7880
if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) {
79-
throw new Error(`Unknown package manager: ${this.bin}`)
81+
log()
82+
warn(
83+
`The package manager ${chalk.red(this.bin)} is ${chalk.red('not officially supported')}.\n` +
84+
`It will be treated like ${chalk.cyan('npm')}, but compatibility issues may occur.\n` +
85+
`See if you can use ${chalk.cyan('--registry')} instead.`
86+
)
87+
PACKAGE_MANAGER_CONFIG[this.bin] = PACKAGE_MANAGER_CONFIG.npm
8088
}
8189
}
8290

0 commit comments

Comments
 (0)