Skip to content

fixes #114 - add windows abstraction to handle file linking #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ember-cli-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module EmberCLI
extend self

autoload :App, "ember-cli/app"
autoload :AppWin, "ember-cli/app_win"
autoload :Configuration, "ember-cli/configuration"
autoload :Helpers, "ember-cli/helpers"
autoload :Middleware, "ember-cli/middleware"
Expand Down
31 changes: 31 additions & 0 deletions lib/ember-cli/app_win.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module EmberCLI
class AppWin < EmberCLI::App

def ember_path
@ember_path ||= app_path.join("node_modules", ".bin", "ember").tap do |path|
fail <<-MSG.strip_heredoc unless path.exist?
No local ember executable found. You should run `npm install`
inside the #{name} app located at #{app_path}
MSG
end
end

def symlink_to_assets_root
exec ("cmd.exe /c \"mklink /J #{assets_path.join(name).to_s.gsub('/', '\\')} #{dist_path.join("assets").to_s.gsub('/', '\\')}\"")
rescue Errno::EEXIST
# Sometimes happens when starting multiple Unicorn workers.
# Ignoring...
end

def command(options={})
watch = options[:watch] ? "--watch" : ""

"\"#{ember_path}.cmd\" build #{watch} --environment #{environment} --output-path \"#{dist_path}\" #{log_pipe}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be right. The code is designed to blow up when ember_path is not an executable file. So, it's not gonna return something sensible that you can just add .cmd to, I think.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I changed it to check exist? is because on windows executable? will always return false here. However I totally forgot that npm will create a .cmd for it which might work.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swelham is right. Windows doesn't understand hashbang (#!) executables, so npm creates a .cmd wrapper that basically calls node.exe <script>. So if an npm creates a binstub on windows, then it also creates a .cmd file so that it can be used as an executable. Ruby does the same thing, except as batch scripts.

end

def log_pipe
"| \"#{tee_path}\" -a \"#{log_path}\"" if tee_path
end

end
end
6 changes: 5 additions & 1 deletion lib/ember-cli/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class Configuration
include Singleton

def app(name, options={})
apps.store name, App.new(name, options)
if RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/
apps.store name, AppWin.new(name, options)
else
apps.store name, App.new(name, options)
end
end

def apps
Expand Down