Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Commit

Permalink
Parse package.info in Rakefile with JSON, not v8
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Bland committed Feb 16, 2016
1 parent 5031e9c commit 4516665
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Rakefile
@@ -1,9 +1,11 @@
require 'bundler/gem_tasks'
require 'json'
require 'rake/testtask'
require 'v8'
require 'zlib'

PACKAGE_INFO = JSON.parse(
File.read(File.join(File.dirname(__FILE__), 'package.json')))

Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/*test.rb']
Expand All @@ -18,11 +20,9 @@ def program_exists?(program)
end

def required_programs
file = File.read 'package.json'
hash = JSON.parse file
result = hash["dependencies"].keys
dev_dep = hash["devDependencies"] || {}
result.concat(dev_dep.keys.each {|k| "#{k} (development)"})
result = PACKAGE_INFO['dependencies'].keys
dev_dep = PACKAGE_INFO['devDependencies'] || {}
result.concat(dev_dep.keys.each { |k| "#{k} (development)" })
end

desc "Check for Node.js and NPM packages"
Expand Down Expand Up @@ -60,13 +60,7 @@ file LIB_LUNR_TARGET => LIB_LUNR_SOURCE do
FileUtils.cp LIB_LUNR_SOURCE, LIB_LUNR_TARGET
end

# TODO(mbland): Extract this and other bits from this Rakefile into a gem.
cxt = V8::Context.new
basedir = File.dirname(__FILE__)
package_json = File.read File.join(basedir, 'package.json')
cxt.eval "var package = #{package_json};"
main_js = cxt[:package].main

main_js = PACKAGE_INFO['main']
search_bundle = File.join 'assets', 'js', 'search-bundle.js'
file search_bundle => main_js do
unless system 'npm', 'run', 'make-bundle'
Expand Down

0 comments on commit 4516665

Please sign in to comment.