From 2d796c340c99b1235311bada3bd0384d0b8cd9ae Mon Sep 17 00:00:00 2001
From: Sean Madsen <sean@seanmadsen.com>
Date: Sun, 29 Jan 2017 08:54:21 -0700
Subject: [PATCH] hooks migrate - only convert a hook if its markdown file is
 missing

---
 content-migration/hooks/migrate-hooks | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/content-migration/hooks/migrate-hooks b/content-migration/hooks/migrate-hooks
index 0008b803..0a3106e1 100755
--- a/content-migration/hooks/migrate-hooks
+++ b/content-migration/hooks/migrate-hooks
@@ -17,11 +17,13 @@ chdir($hooks_dir);
 foreach ($hooks_by_category as $category => $hooks) {
   foreach ($hooks as $hook) {
     $hook_name = $hook['name'];
+    $hook_file = "$hook_name.md";
     $html = "$cache_dir/$hook_name";
-    if ( file_exists($html) ) {
+    if ( file_exists($html) && !file_exists($hook_file) ) {
       echo "converting $hook_name ... ";
       $conversion_status = 1;
-      system("webpage2md $html > $hook_name.md", $conversion_status);
+      system("webpage2md $html > $hook_file", $conversion_status);
+      // TODO fix links that point to wiki using only a slash
       if( $conversion_status == 0 ) {
         echo "done" . PHP_EOL;
       }
@@ -29,9 +31,12 @@ foreach ($hooks_by_category as $category => $hooks) {
         echo "ERROR CONVERTING $hook_name" . PHP_EOL;
       }
     }
-    else {
+    else if ( !file_exists($html) ) {
       echo "WARNING: $hook_name not yet fetched" . PHP_EOL;
     }
+    else if ( file_exists($hook_file) ) {
+      echo "ignoring $hook_name (hook file already exists)" . PHP_EOL;
+    }
   }
 }
 
-- 
GitLab