(dependencies)
| 370 | } |
| 371 | |
| 372 | function install(dependencies) { |
| 373 | let command |
| 374 | let args |
| 375 | |
| 376 | if (!fs.existsSync(path.join(process.cwd(), 'package.json'))) { |
| 377 | dependencies.push('codeceptjs') |
| 378 | throw new Error("Error: 'package.json' file not found. Generate it with 'npm init -y' command.") |
| 379 | } |
| 380 | |
| 381 | if (!installedLocally()) { |
| 382 | console.log('CodeceptJS should be installed locally') |
| 383 | dependencies.push('codeceptjs') |
| 384 | } |
| 385 | |
| 386 | console.log('Installing packages: ', colors.green(dependencies.join(', '))) |
| 387 | |
| 388 | if (fileExists('yarn.lock')) { |
| 389 | command = 'yarnpkg' |
| 390 | args = ['add', '-D', '--exact'] |
| 391 | ;[].push.apply(args, dependencies) |
| 392 | |
| 393 | args.push('--cwd') |
| 394 | args.push(process.cwd()) |
| 395 | } else { |
| 396 | command = 'npm' |
| 397 | args = ['install', '--save-dev', '--loglevel', 'error'].concat(dependencies) |
| 398 | } |
| 399 | |
| 400 | if (process.env._INIT_DRY_RUN_INSTALL) { |
| 401 | args.push('--dry-run') |
| 402 | } |
| 403 | |
| 404 | const { status } = spawn.sync(command, args, { stdio: 'inherit' }) |
| 405 | if (status !== 0) { |
| 406 | throw new Error(`${command} ${args.join(' ')} failed`) |
| 407 | } |
| 408 | return true |
| 409 | } |
no test coverage detected