Class: Supso::Javascript
- Inherits:
-
Object
- Object
- Supso::Javascript
- Defined in:
- lib/supso/javascript.rb
Class Method Summary collapse
- .detect_all_npm_projects! ⇒ Object
- .detect_all_projects! ⇒ Object
- .detect_npm_project!(name, project) ⇒ Object
- .npm_list_command_response ⇒ Object
- .npm_list_json ⇒ Object
Class Method Details
.detect_all_npm_projects! ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/supso/javascript.rb', line 30 def self.detect_all_npm_projects! if !Util.has_command?('npm') return end root_project = Javascript.npm_list_json Javascript.detect_npm_project!(root_project['name'], root_project) end |
.detect_all_projects! ⇒ Object
3 4 5 |
# File 'lib/supso/javascript.rb', line 3 def self.detect_all_projects! Javascript.detect_all_npm_projects! end |
.detect_npm_project!(name, project) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/supso/javascript.rb', line 39 def self.detect_npm_project!(name, project) if !project || !project['dependencies'] return end dependencies = project['dependencies'] dependencies.each_key do |dependency_name| if dependency_name == 'super-source' Project.add(name, nil, { aliases: [{'name' => name, 'platform' => 'npm'}], source: 'npm' }) else Javascript.detect_npm_project!(dependency_name, dependencies[dependency_name]) end end end |
.npm_list_command_response ⇒ Object
7 8 9 10 11 |
# File 'lib/supso/javascript.rb', line 7 def self.npm_list_command_response if Util.has_command?('npm') `npm list --json` end end |
.npm_list_json ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/supso/javascript.rb', line 13 def self.npm_list_json if !Util.has_command?('npm') return end npm_list = Javascript.npm_list_command_response npm_project_data = {} begin npm_project_data = JSON.parse(npm_list) rescue npm_project_data = {} # TODO maybe log this? end npm_project_data end |