quick fix to register method

This commit is contained in:
Zachary Flower 2018-02-16 13:28:41 -07:00
parent f16751a46d
commit 57419fd12c
1 changed files with 9 additions and 4 deletions

View File

@ -5,10 +5,10 @@ module Vagrant
class Alias class Alias
def initialize(env) def initialize(env)
@aliases = Registry.new @aliases = Registry.new
@env = env
aliases_file = env.home_path.join("aliases") if env.aliases_path.file?
if aliases_file.file? env.aliases_path.readlines.each do |line|
aliases_file.readlines.each do |line|
# separate keyword-command pairs # separate keyword-command pairs
keyword, command = interpret(line) keyword, command = interpret(line)
@ -31,6 +31,11 @@ module Vagrant
keyword, command = line.split("=", 2).collect(&:strip) keyword, command = line.split("=", 2).collect(&:strip)
# validate the keyword
if keyword.match(/[\s]/i)
raise Errors::AliasInvalidError, alias: line, message: "Alias keywords must not contain any whitespace."
end
[keyword, command] [keyword, command]
end end
@ -43,7 +48,7 @@ module Vagrant
return exec "#{command[1..-1]} #{args.join(" ")}".strip return exec "#{command[1..-1]} #{args.join(" ")}".strip
end end
return CLI.new(command.split.concat(args), env).execute return CLI.new(command.split.concat(args), @env).execute
end end
end end
end end