Completed
Push — master ( 7a70a9...536f20 )
by Andrii
02:06
created

Npm::runInstall()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
3
/*
4
 * Composer plugin for bower/npm assets
5
 *
6
 * @link      https://github.com/hiqdev/composer-asset-plugin
7
 * @package   composer-asset-plugin
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiqdev\composerassetplugin;
13
14
/**
15
 * NPM package manager class.
16
 *
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
class Npm extends PackageManager
20
{
21
    /**
22
     * @inheritdoc
23
     */
24
    protected $name = 'npm';
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public $file = 'package.json';
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public $phpPackage = 'non existent npmphp';
35
36
    /**
37
     * Minimal npm config.
38
     */
39
    protected $config = [
40
        'name'        => 'composer-asset-plugin',
41
        'description' => "This file is auto-generated with 'hiqdev/composer-asset-plugin'.",
42
        'readme'      => ' ',
43
        'repository'  => array('type'=>'git'),
44
    ];
45
46
    /**
47
     * @inheritdoc
48
     */
49
    protected function runInstall()
50
    {
51
        if ($this->passthru('install')) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->passthru('install') of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
52
            $this->plugin->io->write('failed ' . $name . ' install');
0 ignored issues
show
Bug introduced by
The variable $name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
53
        }
54
    }
55
}
56