From edeb97b78a0a2d91ca1b12c1099fb4aa71d1c3ff Mon Sep 17 00:00:00 2001
From: Shrimadhav U K <shrimadhavuk@gmail.com>
Date: Mon, 12 Jun 2017 09:34:08 +0530
Subject: [PATCH] add edit sequence error

---
 .gitlab-ci.yml |  4 +++
 gulpfile.js    | 87 +++++++++++++++++++++++++++-----------------------
 package.json   |  3 +-
 3 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 373ab45..f7165a7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,5 +7,9 @@ pages:
   artifacts:
     paths:
     - public
+  cache:
+    paths:
+      - node_modules
+    key: project
   only:
   - master
diff --git a/gulpfile.js b/gulpfile.js
index c7e0fbe..852d17b 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -11,6 +11,7 @@ var connect = require('gulp-connect');
 var connectProxy = require('gulp-connect-proxy');
 
 var yamlinc = require("gulp-yaml-include");
+var runSequence = require('run-sequence');
 var readYaml = require('read-yaml');
 var glob = require("glob");
 
@@ -46,7 +47,7 @@ gulp.task('jslint', function() {
     .pipe(jshint.reporter('default'));
 });
 
-gulp.task('pughtml', function() {
+gulp.task('GenerateIndexPage', function(){
   gulp.src('pug/pages/*.pug')
     .pipe(pug({
       pretty: true,
@@ -55,48 +56,54 @@ gulp.task('pughtml', function() {
       }
     }))
     .pipe(gulp.dest('public'));
-  var yamlData = gulp.src("events/index.yaml")
+});
+
+gulp.task('GenerateEventsYAML', function(){
+  return gulp.src("events/index.yaml")
         .pipe(yamlinc())
         .pipe(gulp.dest('public/events'));
+})
+
+gulp.task('GenerateEventsPage', function(){
+    readYaml('public/events/index.yaml', function(err, ydata) {
+      if (err) throw err;
+      gulp.src('pug/templates/events.pug')
+        .pipe(pug({
+          pretty: true,
+          data: {
+            debug: true,
+            events: ydata
+          }
+        }))
+        .pipe(concat('index' + '.html'))
+        .pipe(gulp.dest('public/events'));
+    });
+    glob("events/TheRealEvents/*.yaml", {}, function (er, files) {
+      var nooffiles = files.length;
+      for(var i = 0; i < nooffiles; i++){
+        readYaml(files[i], function(err, ydata) {
+          if (err) throw err;
+          var id = ydata.id;
+          gulp.src('pug/templates/individual_event_page.pug')
+            .pipe(pug({
+              pretty: true,
+              data: {
+                debug: true,
+                evt: ydata
+              }
+            }))
+            .pipe(concat(id + '.html'))
+            .pipe(gulp.dest('public/events'));
+        });
+      }
+    });
+})
 
-  readYaml('public/events/index.yaml', function(err, ydata) {
-    // if (err) throw err;
-    gulp.src('pug/templates/events.pug')
-      .pipe(pug({
-        pretty: true,
-        data: {
-          debug: true,
-          events: ydata
-        }
-      }))
-      .pipe(concat('index' + '.html'))
-      .pipe(gulp.dest('public/events'));
-  });
-  // options is optional
-  glob("events/TheRealEvents/*.yaml", {}, function (er, files) {
-    // files is an array of filenames.
-    // If the `nonull` option is set, and nothing
-    // was found, then files is ["**/*.js"]
-    // er is an error object or null.
-    var nooffiles = files.length;
-    for(var i = 0; i < nooffiles; i++){
-      readYaml(files[i], function(err, ydata) {
-        if (err) throw err;
-        var id = ydata.id;
-        gulp.src('pug/templates/individual_event_page.pug')
-          .pipe(pug({
-            pretty: true,
-            data: {
-              debug: true,
-              evt: ydata
-            }
-          }))
-          .pipe(concat(id + '.html'))
-          .pipe(gulp.dest('public/events'));
-      });
-
-    }
-  });
+gulp.task('pughtml', function(){
+  runSequence('GenerateEventsYAML',[
+    'GenerateIndexPage',
+    'GenerateEventsPage'
+  ])
 });
 
 gulp.task('cssmin', function() {
diff --git a/package.json b/package.json
index 2727f90..a13a512 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,8 @@
     "gulp-uglify": "^3.0.0",
     "gulp-yaml-data": "^0.2.0",
     "gulp-yaml-include": "^0.2.0",
-    "read-yaml": "^1.1.0"
+    "read-yaml": "^1.1.0",
+    "run-sequence": "^1.2.2"
   },
   "dependencies": {
     "Respond.js": "git+https://github.com/scottjehl/Respond.git#1.4.0",
-- 
GitLab