(command, options)
| 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 = []; |
no outgoing calls
no test coverage detected