src/NodePackageManagers/Proxy.php
protected function getNodePackageManager() {
		$is_windows = strtolower( substr( PHP_OS, 0, 3 ) ) === 'win';
		$node_package_managers = [
			'yarn' => Yarn::class,
			'npm' => Npm::class,
		];

		foreach ( $node_package_managers as $manager => $class ) {
			$command = $is_windows ? 'where ' . escapeshellarg( $manager ) : 'which ' . escapeshellarg( $manager );

			try {
				$output = App::execute( $command );
			} catch ( ProcessFailedException $e ) {
				continue;
			}

			if ( ! trim( $output ) ) {
				continue;
			}

			return new $class();
		}

		throw new RuntimeException( 'Could not find a node package manager. Please check if npm is added to your PATH.' );
	}
protected function getNodePackageManager() {
		$is_windows = strtolower( substr( PHP_OS, 0, 3 ) ) === 'win';
		$node_package_managers = [
			'yarn' => Yarn::class,
			'npm' => Npm::class,
		];

		foreach ( $node_package_managers as $manager => $class ) {
			$command = $is_windows ? 'where ' . escapeshellarg( $manager ) : 'which ' . escapeshellarg( $manager );

			try {
				$output = App::execute( $command );
			} catch ( ProcessFailedException $e ) {
				continue;
			}

			if ( ! trim( $output ) ) {
				continue;
			}

			return new $class();
		}

		throw new RuntimeException( 'Could not find a node package manager. Please check if npm is added to your PATH.' );
	}
protected function getNodePackageManager ( ) { $ is_windows = strtolower ( substr ( PHP_OS , 0 , 3 ) ) === 'win' ; $ node_package_managers = [ 'yarn' => Yarn :: class , 'npm' => Npm :: class , ] ; foreach ( $ node_package_managers as $ manager => $ class ) { $ command = $ is_windows ? 'where ' . escapeshellarg ( $ manager ) : 'which ' . escapeshellarg ( $ manager ) ; try { $ output = App :: execute ( $ command ) ; } catch ( ProcessFailedException $ e ) { continue ; } if ( ! trim ( $ output ) ) { continue ; } return new $ class ( ) ; } throw new RuntimeException ( 'Could not find a node package manager. Please check if npm is added to your PATH.' ) ; }
Get an instance of the first available package manager

@return NodePackageManagerInterface
Get an instance of the first available package manager