Skip to content

Commit

Permalink
fix: update ok_failed function calls in Rakefile to include error han…
Browse files Browse the repository at this point in the history
…dling flags
  • Loading branch information
rcmdnk committed Sep 4, 2024
1 parent 56e378e commit fe79836
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 70 deletions.
68 changes: 34 additions & 34 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ task :generate, :opt do |t, args|
end
end

ok_failed("rm -f .integrated")
ok_failed("rm -f .preview-mode")
ok_failed("rm -f .integrated", false)
ok_failed("rm -f .preview-mode", false)
end

desc "Same as generate"
Expand Down Expand Up @@ -379,15 +379,15 @@ task :isolate, :filename do |t, args|
end
end
end
ok_failed("touch .isolated")
ok_failed("touch .isolated", false)
end

desc "Move all stashed posts back into the posts directory, ready for site generation."
task :integrate do
FileUtils.mv Dir.glob("#{full_stash_dir}/*"), "#{source_dir}/#{posts_dir}/"
FileUtils.mv Dir.glob("#{full_stash_root_dir}/*"), "#{source_dir}/"
ok_failed("rm -f .isolated")
ok_failed("touch .integrated")
ok_failed("rm -f .isolated", false)
ok_failed("touch .integrated", false)
end

desc "Clean out caches: .pygments-cache, .gist-cache, .sass-cache, thumbnail"
Expand Down Expand Up @@ -437,7 +437,7 @@ task :deploy, :deploy_method do |t, args|
# Check if preview posts exists, which should not be published
if File.exist?(".integrated") or File.exist?(".isolated")
puts "## Found isolated history, regenerating files ..."
ok_failed("rm -f .integrated .isolated")
ok_failed("rm -f .integrated .isolated", false)
Rake::Task[:integrate].execute
Rake::Task[:generate].execute
end
Expand All @@ -450,7 +450,7 @@ task :deploy, :deploy_method do |t, args|
Rake::Task[:copydot].invoke(source_dir, public_dir)

# Check if files are fine or not
ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi")
ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi", false)

if args.deploy_method
deploy_method = args.deploy_method;
Expand Down Expand Up @@ -490,28 +490,28 @@ task :rsync do
exclude = "--exclude-from '#{File.expand_path('./rsync-exclude')}'"
end
puts "## Deploying website via Rsync"
ok_failed("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}")
ok_failed("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}", false)
end

desc "deploy public directory to github pages"
multitask :push do
puts "## Deploying branch to Github Pages "
puts "## Pulling any updates from Github Pages "
cd "#{deploy_dir}" do
Bundler.with_original_env { ok_failed("git pull") }
Bundler.with_original_env { ok_failed("git pull", false) }
end
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
Rake::Task[:copydot].invoke(public_dir, deploy_dir)
puts "\n## Copying #{public_dir} to #{deploy_dir}"
cp_r "#{public_dir}/.", deploy_dir
cd "#{deploy_dir}" do
ok_failed("git add -A")
ok_failed("git add -A", false)
message = "Site updated at #{Time.now.utc}"
puts "\n## Committing: #{message}"
ok_failed("git commit -m \"#{message}\"")
ok_failed("git commit -m \"#{message}\"", false)
puts "\n## Pushing generated #{deploy_dir} website"
output = (use_token)? " >/dev/null 2>&1":""
Bundler.with_original_env { ok_failed("git push origin #{deploy_branch} #{output}") }
Bundler.with_original_env { ok_failed("git push origin #{deploy_branch} #{output}", false) }
puts "\n## Github Pages deploy complete"
end
end
Expand All @@ -527,22 +527,22 @@ multitask :push_ex do
rm_rf deploy_dir
mkdir_p deploy_dir
cd "#{deploy_dir}" do
ok_failed("git init")
ok_failed("git remote add origin #{repo_url}")
ok_failed("git init", false)
ok_failed("git remote add origin #{repo_url}", false)
end

Rake::Task[:copydot].invoke(public_dir, deploy_dir)
puts "\n## Copying #{public_dir} to #{deploy_dir}"
cp_r "#{public_dir}/.", deploy_dir
cd "#{deploy_dir}" do
ok_failed("git add -A")
ok_failed("git add -A", false)
puts "\n## Commiting: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
ok_failed("git commit -m \"#{message}\" >/dev/null")
ok_failed("git branch -m #{deploy_branch}")
ok_failed("git commit -m \"#{message}\" >/dev/null", false)
ok_failed("git branch -m #{deploy_branch}", false)
puts "\n## Pushing generated #{deploy_dir} website"
output = (use_token) ? " >/dev/null 2>&1" : ""
Bundler.with_unbundled_env { ok_failed("git push -u -f origin #{deploy_branch} #{output}") }
Bundler.with_unbundled_env { ok_failed("git push -u -f origin #{deploy_branch} #{output}", false) }
puts "\n## Github Pages deploy complete"
end
end
Expand Down Expand Up @@ -603,19 +603,19 @@ task :setup_github_pages, [:repo, :yes] do |t, args|
use_token_val = use_token ? "true" : "false"
unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil?
# If octopress is still the origin remote (from cloning) rename it to octopress
ok_failed("git remote rename origin octopress")
ok_failed("git remote rename origin octopress", false)
if branch == 'master'
# If this is a user/organization pages repository, add the correct origin remote
# and checkout the source branch for committing changes to the blog source.
ok_failed("git remote add origin #{repo_url}")
ok_failed("git remote add origin #{repo_url}", false)
if use_token
puts "Added given remote as origin"
else
puts "Added remote #{repo_url} as origin"
end
ok_failed("git config branch.master.remote origin")
ok_failed("git config branch.master.remote origin", false)
puts "Set origin as default remote"
ok_failed("git branch -m master source")
ok_failed("git branch -m master source", false)
puts "Master branch renamed to 'source' for committing your blog source files"
end
end
Expand Down Expand Up @@ -659,12 +659,12 @@ task :setup_github_pages, [:repo, :yes] do |t, args|
rm_rf deploy_dir
mkdir deploy_dir
cd "#{deploy_dir}" do
ok_failed("git init")
ok_failed("echo 'My Octopress Page is coming soon &hellip;' > index.html")
ok_failed("git add -A")
ok_failed("git commit -m \"Octopress init\"")
ok_failed("git branch -m #{deploy_branch}") unless branch == 'master'
ok_failed("git remote add origin #{repo_url}")
ok_failed("git init", false)
ok_failed("echo 'My Octopress Page is coming soon &hellip;' > index.html", false)
ok_failed("git add -A", false)
ok_failed("git commit -m \"Octopress init\"", false)
ok_failed("git branch -m #{deploy_branch}", false) unless branch == 'master'
ok_failed("git remote add origin #{repo_url}", false)
rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
end
if use_token
Expand All @@ -676,7 +676,7 @@ task :setup_github_pages, [:repo, :yes] do |t, args|
File.open(__FILE__, 'w') do |f|
f.write rakefile
end
ok_failed("rake set_root_dir[#{project}]")
ok_failed("rake set_root_dir[#{project}]", false)
end

def get_stdin(message)
Expand Down Expand Up @@ -746,7 +746,7 @@ def grep_check(word, grep_option, opt)
echo #{comment};\
printf \"\\\\e[m\\\\n\";\
exit 1;\
fi")
fi", false)
end

desc 'Check source'
Expand Down Expand Up @@ -777,7 +777,7 @@ task :check, :opt do |t, args|
exit 1;\
fi;\
done < #{word_avoid};\
fi")
fi", false)
puts ""
end

Expand Down Expand Up @@ -886,10 +886,10 @@ task :ping do
end

task :test do
#ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi")
#ok_failed("cd #{public_dir};pwd;cd -")
#ok_failed("if [ -f #{word_avoid} ];then while read a;do if ret=`grep -i -r -q $a #{public_dir}`;then echo \"A word $a is included, must be avoided!!!\"; echo $ret; exit 1;fi; done < #{word_avoid};fi", false)
#ok_failed("cd #{public_dir};pwd;cd -", false)
#raise "eror"
ok_failed("git ls >& log")
ok_failed("git ls >& log", false)
end

def ok_failed(command, print_ok = false)
Expand Down
Loading

0 comments on commit fe79836

Please sign in to comment.