MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / findPackageManager

Method findPackageManager

lib/tasks/npm-task.js:142–186  ·  view source on GitHub ↗

* This method will determine what package manager (npm or yarn) should be * used to install the npm dependencies. * * Setting `this.useYarn` to `true` or `false` will force the use of yarn * or npm respectively. * * If `this.useYarn` is not set we check if `yarn.lock` exists and if

(packageManager = null)

Source from the content-addressed store, hash-verified

140 * @return {Promise}
141 */
142 async findPackageManager(packageManager = null) {
143 if (packageManager === 'yarn') {
144 logger.info('yarn requested -> trying yarn');
145 return this.checkYarn();
146 }
147
148 if (packageManager === 'npm') {
149 logger.info('npm requested -> using npm');
150 return this.checkNpmVersion();
151 }
152
153 if (packageManager === 'pnpm') {
154 logger.info('pnpm requested -> using pnpm');
155 return this.checkPNPM();
156 }
157
158 if (this.hasYarnLock()) {
159 logger.info('yarn.lock found -> trying yarn');
160 try {
161 const yarnResult = await this.checkYarn();
162 logger.info('yarn found -> using yarn');
163 return yarnResult;
164 } catch (_err) {
165 logger.info('yarn not found');
166 }
167 } else {
168 logger.info('yarn.lock not found');
169 }
170
171 if (await this.hasPNPMLock()) {
172 logger.info('pnpm-lock.yaml found -> trying pnpm');
173 try {
174 let result = await this.checkPNPM();
175 logger.info('pnpm found -> using pnpm');
176 return result;
177 } catch (_err) {
178 logger.info('pnpm not found');
179 }
180 } else {
181 logger.info('pnpm-lock.yaml not found');
182 }
183
184 logger.info('using npm');
185 return this.checkNpmVersion();
186 }
187
188 async run(options) {
189 this.packageManager = await this.findPackageManager(options.packageManager);

Callers 2

runMethod · 0.95
npm-task-test.jsFile · 0.80

Calls 5

checkYarnMethod · 0.95
checkNpmVersionMethod · 0.95
checkPNPMMethod · 0.95
hasYarnLockMethod · 0.95
hasPNPMLockMethod · 0.95

Tested by

no test coverage detected