lib/learn_submit/submission.rb in learn-submit-1.2.0 vs lib/learn_submit/submission.rb in learn-submit-1.3.0
- old
+ new
@@ -1,6 +1,7 @@
require 'yaml'
+require 'json'
module LearnSubmit
class Submission
attr_reader :git, :client, :file_path, :message, :save, :token, :dot_learn
@@ -159,17 +160,31 @@
end
end
def after_ide_submission(repo_name)
return unless dot_learn && dot_learn['after_ide_submission']
- return unless Socket.gethostname.end_with? '.students.learn.co'
+ return unless ENV['IDE_CONTAINER'] == 'true'
ide_user_home = "/home/#{ENV['USER']}"
- path = "#{ide_user_home}/code/labs/#{repo_name}/"
- url = dot_learn['after_ide_submission']
- File.open("#{ide_user_home}/.fs_changes.log", 'a') do |f|
- f.puts "#{path} LEARN_SUBMIT #{url}"
+ payload = {
+ command: 'after_ide_submission',
+ url: dot_learn['after_ide_submission']
+ }
+
+ File.open("#{ide_user_home}/.custom_commands.log", 'a') do |f|
+ f.puts payload.to_json
+ end
+
+ # TODO: the following can be removed when IDE versions <2.0 are no
+ # longer supported. There is no '.fs_changes.log' for users on >2.0.
+ if File.exist?("#{ide_user_home}/.fs_changes.log")
+ path = "#{ide_user_home}/code/labs/#{repo_name}/"
+ url = dot_learn['after_ide_submission']
+
+ File.open("#{ide_user_home}/.fs_changes.log", 'a') do |f|
+ f.puts "#{path} LEARN_SUBMIT #{url}"
+ end
end
end
end
end