Skip to content

Commit

Permalink
Merge branch 'safe-undefined' of git@github.com:pivotal/jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
xian committed Nov 27, 2009
2 parents 23c5289 + 7653107 commit 40ff1cb
Show file tree
Hide file tree
Showing 14 changed files with 2,164 additions and 2,168 deletions.
43 changes: 38 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec/jasmine_helper.
def jasmine_sources
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
sources
end

def jasmine_filename(version)
Expand All @@ -26,19 +27,53 @@ def start_jasmine_server(jasmine_includes = nil)
:jasmine_files => jasmine_includes)
end

task :default => 'jasmine:dist'

namespace :jasmine do

desc 'Prepares for distribution'
task :dist => ['jasmine:build', 'jasmine:doc']

desc 'Check jasmine sources for coding problems'
task :lint do
passed = true
jasmine_sources.each do |src|
lines = File.read(src).split(/\n/)
lines.each_index do |i|
line = lines[i]
undefineds = line.scan(/.?undefined/)
if undefineds.include?(" undefined") || undefineds.include?("\tundefined")
puts "Dangerous undefined at #{src}:#{i}:\n > #{line}"
passed = false
end
end
end

unless passed
puts "Lint failed!"
exit 1
end
end

desc 'Builds lib/jasmine from source'
task :build => 'jasmine:doc' do
task :build => :lint do
puts 'Building Jasmine from source'
require 'json'

sources = jasmine_sources
version = version_hash

old_jasmine_files = Dir.glob('lib/jasmine*.js')
old_jasmine_files.each do |file|
File.delete(file)
end

jasmine = File.new("lib/#{jasmine_filename version}", 'w')
jasmine.puts(File.read(sources.shift))

sources.each do |source_filename|
jasmine.puts(File.read(source_filename))
end

jasmine.puts %{
jasmine.version_= {
"major": #{version['major']},
Expand All @@ -47,9 +82,7 @@ jasmine.version_= {
"revision": #{Time.now.to_i}
};
}
sources.each do |source_filename|
jasmine.puts(File.read(source_filename))
end

jasmine.close
end

Expand Down
Loading

0 comments on commit 40ff1cb

Please sign in to comment.