Sha256: 7c813830613788173c8e608cb021da048fd2b94eb953c2281a5cd59317196d7a

Contents?: true

Size: 639 Bytes

Versions: 3

Compression:

Stored size: 639 Bytes

Contents

require 'json'
require 'tempfile'

module LicenseFinder
  class NPM < PackageManager
    def current_packages
      NpmPackage.packages_from_json(npm_json, detected_package_path)
    end

    def self.package_management_command
      'npm'
    end

    private

    def possible_package_paths
      [project_path.join('package.json')]
    end

    def npm_json
      command = "#{NPM.package_management_command} list --json --long"
      stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
      raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?

      JSON.parse(stdout)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
license_finder-4.0.2 lib/license_finder/package_managers/npm.rb
license_finder-4.0.1 lib/license_finder/package_managers/npm.rb
license_finder-3.1.1 lib/license_finder/package_managers/npm.rb