~singpolyma/rld

001fda730aee056ce21da187f2c820b1e0bdfc7e — Stephen Paul Weber 7 months ago 9ec6044
Fix relative paths
1 files changed, 3 insertions(+), 2 deletions(-)

M bin/rld
M bin/rld => bin/rld +3 -2
@@ 94,11 94,12 @@ class Linker < Parser::TreeRewriter
		in [:send, nil, :require, [:str, arg] => argnode]
			path = require(arg)
			realpath = Pathname.new(path).realdirpath
			dir = Pathname.new(node.location.expression.source_buffer.name).dirname.expand_path
			if path.start_with?($options[:p].to_s)
				path = Pathname.new(path).relative_path_from($options[:p]).to_s
				path = Pathname.new(path).relative_path_from(dir).to_s
				replace(node.location.expression, "require_relative " + path.inspect)
			elsif realpath.to_s.start_with?($options[:p].to_s)
				path = realpath.relative_path_from($options[:p]).to_s
				path = realpath.relative_path_from(dir).to_s
				replace(node.location.expression, "require_relative " + path.inspect)
			else
				replace(argnode.location.expression, path.inspect)