From 0c340aaf5f9a774e7046ad208b0f89ef2e96750b Mon Sep 17 00:00:00 2001 From: Jace Bennett Date: Fri, 22 Mar 2013 18:15:10 -0400 Subject: [PATCH 1/2] changed all npm executable refences to use npm bin to resolve the correct path --- Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 4a03e93..3b99130 100644 --- a/Rakefile +++ b/Rakefile @@ -4,8 +4,8 @@ task :default => [:build] desc 'Create js files from coffee sources' task :build do - system("cd #{root} && bundle exec coffee --compile --output . src/isolate.coffee") - system("cd #{root} && bundle exec coffee --compile spec") + system("cd #{root} && bundle exec `npm bin`/coffee --compile --output . src/isolate.coffee") + system("cd #{root} && bundle exec `npm bin`/coffee --compile spec") end test_namespace = namespace :test do @@ -13,7 +13,7 @@ test_namespace = namespace :test do task :commonjs => :build do debug = isDebug?() ? ' debug' : '' Dir.chdir root do - system "NODE_PATH=.:./spec:./spec/modules_for_testing/commonjs:$NODE_PATH ./node_modules/.bin/mocha --compilers coffee:coffee-script --reporter spec #{debug} ./spec/commonjs.spec.coffee" + system "NODE_PATH=.:./spec:./spec/modules_for_testing/commonjs:$NODE_PATH `npm bin`/mocha --compilers coffee:coffee-script --reporter spec #{debug} ./spec/commonjs.spec.coffee" end end @@ -44,7 +44,7 @@ test_namespace = namespace :test do Dir.chdir root do puts "Running tests against requirejs version: [#{version}]" system "npm install requirejs@#{version}" - cmd = "NODE_PATH=.:./spec:$NODE_PATH ./node_modules/.bin/mocha --compilers coffee:coffee-script --globals 'define,requirejsVars' --reporter spec #{debug} ./spec/requirejs.spec.coffee" + cmd = "NODE_PATH=.:./spec:$NODE_PATH `npm bin`/mocha --compilers coffee:coffee-script --globals 'define,requirejsVars' --reporter spec #{debug} ./spec/requirejs.spec.coffee" if isDebug?() system cmd else From 287866ea1c0b7bb34f04694046ba3d0187467c4d Mon Sep 17 00:00:00 2001 From: James Maroney Date: Fri, 22 Mar 2013 22:43:15 -0400 Subject: [PATCH 2/2] @bnwasteland Here are some updates that make the commands seem to execute cross-platform. Sadly, they still don't behave correctly in Windows, so this certainly isn't 100% right. --- Rakefile | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index 3b99130..342aaa9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,21 @@ root=File.dirname __FILE__ +npm_bin=`npm bin`.strip! task :default => [:build] +def run(cmd) + puts cmd + output = `#{cmd}` + print output + return output +end + desc 'Create js files from coffee sources' task :build do - system("cd #{root} && bundle exec `npm bin`/coffee --compile --output . src/isolate.coffee") - system("cd #{root} && bundle exec `npm bin`/coffee --compile spec") + Dir.chdir root do + run "#{npm_bin}/coffee --compile --output . src/isolate.coffee" + run "#{npm_bin}/coffee --compile spec" + end end test_namespace = namespace :test do @@ -13,7 +23,8 @@ test_namespace = namespace :test do task :commonjs => :build do debug = isDebug?() ? ' debug' : '' Dir.chdir root do - system "NODE_PATH=.:./spec:./spec/modules_for_testing/commonjs:$NODE_PATH `npm bin`/mocha --compilers coffee:coffee-script --reporter spec #{debug} ./spec/commonjs.spec.coffee" + ENV["NODE_PATH"] = ".:./spec:./spec/modules_for_testing/commonjs:#{ENV["NODE_PATH"]}" + run "#{npm_bin}/mocha --compilers coffee:coffee-script --reporter spec #{debug} ./spec/commonjs.spec.coffee" end end @@ -43,12 +54,13 @@ test_namespace = namespace :test do versions_to_test_against.each do |version| Dir.chdir root do puts "Running tests against requirejs version: [#{version}]" - system "npm install requirejs@#{version}" - cmd = "NODE_PATH=.:./spec:$NODE_PATH `npm bin`/mocha --compilers coffee:coffee-script --globals 'define,requirejsVars' --reporter spec #{debug} ./spec/requirejs.spec.coffee" + run "npm install requirejs@#{version}" + ENV["NODE_PATH"] = ".:./spec:#{ENV["NODE_PATH"]}" + cmd = "#{npm_bin}/mocha --compilers coffee:coffee-script --globals 'define,requirejsVars' --reporter spec #{debug} ./spec/requirejs.spec.coffee" if isDebug?() system cmd else - puts tests_output = `#{cmd}` + tests_output = run cmd raise('Failed to load Tests') if tests_output.include? '0 tests complete' tests_passed = $?.success? raise('Tests Failed') unless tests_passed