remove jasmine server; use jasmine init to copy (or append) a Rakefile with common jasmine tasks
This commit is contained in:
43
bin/jasmine
43
bin/jasmine
@@ -1,26 +1,35 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'rubygems'
|
||||
cwd = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||
require File.expand_path(File.join(cwd, "lib", "jasmine-ruby", "jasmine_helper.rb"))
|
||||
require 'rake'
|
||||
|
||||
#to load JasmineHelper overrides
|
||||
if ARGV[1]
|
||||
require File.expand_path(File.join(Dir.pwd, ARGV[1]))
|
||||
def cwd
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||
end
|
||||
|
||||
if ARGV[0] == 'server'
|
||||
require File.expand_path(File.join(cwd, "jasmine/contrib/ruby/jasmine_spec_builder"))
|
||||
puts "your tests are here:"
|
||||
puts " http://localhost:8888/run.html"
|
||||
Jasmine::SimpleServer.start(8888,
|
||||
lambda { JasmineHelper.specs },
|
||||
JasmineHelper.dir_mappings,
|
||||
:spec_helpers => JasmineHelper.spec_helpers)
|
||||
def expand(*paths)
|
||||
File.expand_path(File.join(*paths))
|
||||
end
|
||||
|
||||
def rakefile_path
|
||||
expand(cwd, 'templates/Rakefile')
|
||||
end
|
||||
|
||||
if ARGV[0] == 'init'
|
||||
require 'ftools'
|
||||
File.makedirs('spec')
|
||||
dest_dir = File.expand_path(File.join(Dir.pwd, 'spec'))
|
||||
File.copy(File.expand_path(File.join(cwd, 'templates/example_spec.js')), dest_dir)
|
||||
end
|
||||
File.makedirs('spec/javascripts')
|
||||
dest_root = expand(Dir.pwd, 'spec')
|
||||
dest_spec = expand(Dir.pwd, 'spec/javascripts')
|
||||
File.copy(expand(cwd, 'templates/example_spec.js'), dest_spec)
|
||||
if File.exist?(expand(Dir.pwd, 'Rakefile'))
|
||||
existing_rakefile = expand(Dir.pwd, 'Rakefile')
|
||||
load existing_rakefile
|
||||
unless Rake::Task.task_defined?('jasmine')
|
||||
open(existing_rakefile, 'a') do |f|
|
||||
f.write(File.read(rakefile_path))
|
||||
end
|
||||
end
|
||||
else
|
||||
File.copy(rakefile_path, Dir.pwd)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user