Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f5daa150b92a
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d126b0e80fc9
Choose a head ref
  • 6 commits
  • 4 files changed
  • 1 contributor

Commits on Jan 15, 2015

  1. Decorate missing requires errors with useful stuff

    Like the file that was trying to require.
    elia committed Jan 15, 2015
    Copy the full SHA
    e14bdaa View commit details
  2. Copy the full SHA
    b4cae43 View commit details
  3. Copy the full SHA
    620cb60 View commit details
  4. Copy the full SHA
    f1f684b View commit details
  5. Copy the full SHA
    6fa1209 View commit details
  6. Add IO#tty?

    elia committed Jan 15, 2015
    Copy the full SHA
    d126b0e View commit details
Showing with 37 additions and 10 deletions.
  1. +12 −3 lib/opal/builder.rb
  2. +4 −0 opal/corelib/io.rb
  3. +5 −5 opal/corelib/kernel.rb
  4. +16 −2 stdlib/nodejs/process.rb
15 changes: 12 additions & 3 deletions lib/opal/builder.rb
Original file line number Diff line number Diff line change
@@ -38,6 +38,9 @@ def build_str source, filename, options = {}
requires.map { |r| process_require(r, options) }
processed << asset
self
rescue MissingRequire
$stdout.puts "A file required by #{filename.inspect} wasn't found."
raise
end

def build_require(path, options = {})
@@ -90,9 +93,12 @@ def processor_for(source, filename, path, options)
return processor.new(source, filename, compiler_options.merge(options))
end

class MissingRequire < LoadError
end

def read(path)
path_reader.read(path) or
raise ArgumentError, "can't find file: #{path.inspect} in #{path_reader.paths.inspect}"
raise MissingRequire, "can't find file: #{path.inspect} in #{path_reader.paths.inspect}"
end

def process_require(filename, options)
@@ -112,12 +118,15 @@ def process_require(filename, options)

path = path_reader.expand(filename).to_s unless stub?(filename)
asset = processor_for(source, filename, path, options.merge(requirable: true))
process_requires(asset.requires+tree_requires(asset, path), options)
process_requires(filename, asset.requires+tree_requires(asset, path), options)
processed << asset
end

def process_requires(requires, options)
def process_requires(source_filename, requires, options)
requires.map { |r| process_require(r, options) }
rescue MissingRequire
$stdout.puts "A file required by #{source_filename.inspect} wasn't found."
raise
end

def already_processed
4 changes: 4 additions & 0 deletions opal/corelib/io.rb
Original file line number Diff line number Diff line change
@@ -3,6 +3,10 @@ class IO
SEEK_CUR = 1
SEEK_END = 2

def tty?
@tty
end

attr_accessor :write_proc

def write(string)
10 changes: 5 additions & 5 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -71,6 +71,11 @@ def Array(object, *args, &block)
}
end

def at_exit(&block)
$__at_exit__ ||= []
$__at_exit__ << block
end

# Opal does not support #caller, but we stub it as an empty array to not
# break dependant libs
def caller
@@ -581,10 +586,5 @@ def to_s
"#<#{self.class}:0x#{__id__.to_s(16)}>"
end

def at_exit(&block)
$__at_exit__ ||= []
$__at_exit__ << block
end

alias untaint taint
end
18 changes: 16 additions & 2 deletions stdlib/nodejs/process.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
module Kernel
def exit(status)
`process.exit(status)`
def exit(status = true)
$__at_exit__.reverse.each(&:call) if $__at_exit__
`process.exit(status === true ? 0 : status)`
end

def caller
%x{
var stack;
try {
var err = Error("my error");
throw err;
} catch(e) {
stack = e.stack;
}
return stack.$split("\n").slice(3);
}
end
end