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

Method toYarnArgs

lib/tasks/npm-task.js:251–294  ·  view source on GitHub ↗
(command, options)

Source from the content-addressed store, hash-verified

249 }
250
251 toYarnArgs(command, options) {
252 let args = [];
253
254 if (command === 'install') {
255 if (options.save) {
256 args.push('add');
257 } else if (options['save-dev']) {
258 args.push('add', '--dev');
259 } else if (options.packages) {
260 throw new Error(`npm command "${command} ${options.packages.join(' ')}" can not be translated to Yarn command`);
261 } else {
262 args.push('install');
263 }
264
265 if (options['save-exact']) {
266 args.push('--exact');
267 }
268
269 if ('optional' in options && !options.optional) {
270 args.push('--ignore-optional');
271 }
272 } else if (command === 'uninstall') {
273 args.push('remove');
274 } else {
275 throw new Error(`npm command "${command}" can not be translated to Yarn command`);
276 }
277
278 if (options.verbose) {
279 args.push('--verbose');
280 }
281
282 if (options.packages) {
283 args = args.concat(options.packages);
284 }
285
286 // Yarn v2 defaults to non-interactive
287 // with an optional -i flag
288
289 if (semver.lt(this.packageManager.version, '2.0.0')) {
290 args.push('--non-interactive');
291 }
292
293 return args;
294 }
295
296 toPNPMArgs(command, options) {
297 let args = [];

Callers 2

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

Calls

no outgoing calls

Tested by

no test coverage detected