Method: Node::Compiler#init_entrance

Defined in:
lib/node/compiler.rb

#init_entranceObject

Raises:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/node/compiler.rb', line 53

def init_entrance
  # Important to expand_path; otherwiser the while would not be right
  @entrance = File.expand_path(@entrance)
  raise Error, "Cannot find entrance #{@entrance}." unless File.exist?(@entrance)
  if @options[:project_root]
    @project_root = File.expand_path(@options[:project_root])
  else
    @project_root = File.dirname(@entrance)
    # this while has to correspond with the expand_path above
    while !File.exist?(File.expand_path('./package.json', @project_root))
      break if '/' == @project_root
      @project_root = File.expand_path('..', @project_root)
    end
  end
  unless File.exist?(File.expand_path('./package.json', @project_root))
    raise Error, "Cannot find a package.json at the project root #{@project_root}"
  end
end