Skip to content
This repository
Browse code

Better fetching of documentation resources. Updated for DocPad v6.21

  • Loading branch information...
commit 69eb75406bee97b6252554206c395318903f9488 1 parent 25b4ed9
Benjamin Arthur Lupton authored January 04, 2013
37  app/out/docpad.js
... ...
@@ -1,7 +1,7 @@
1 1
 // Generated by CoffeeScript 1.4.0
2 2
 var appPath, balUtil, docpadConfig, feedr, fsUtil, getCategoryName, getLabelName, getLinkName, getName, getProjectName, humanize, moment, navigationData, pathUtil, requireFresh, rootPath, sitePath, strUtil, textData, _,
3  
-  __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
4  
-  __hasProp = {}.hasOwnProperty;
  3
+  __hasProp = {}.hasOwnProperty,
  4
+  __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
5 5
 
6 6
 fsUtil = require('fs');
7 7
 
@@ -205,12 +205,9 @@ docpadConfig = {
205 205
       docpad = this.docpad;
206 206
       config = docpad.getConfig();
207 207
       tasks = new balUtil.Group(next);
208  
-      if (opts.reset === false || __indexOf.call(docpad.getEnvironments(), 'development') >= 0) {
209  
-        return next();
210  
-      }
211  
-      docpad.log('info', "Updating Documentation...");
212 208
       repos = {
213 209
         'docpad-documentation': {
  210
+          name: 'DocPad Documentation',
214 211
           path: pathUtil.join(config.documentsPaths[0], 'docs'),
215 212
           url: 'git://github.com/bevry/docpad-documentation.git'
216 213
         }
@@ -219,18 +216,24 @@ docpadConfig = {
219 216
         if (!__hasProp.call(repos, repoKey)) continue;
220 217
         repoValue = repos[repoKey];
221 218
         tasks.push(repoValue, function(complete) {
222  
-          return balUtil.initOrPullGitRepo(balUtil.extend({
223  
-            remote: 'origin',
224  
-            branch: 'master',
225  
-            output: true,
226  
-            next: function(err) {
227  
-              if (err) {
228  
-                docpad.warn(err);
  219
+          var _this = this;
  220
+          if (opts.reset === true || fs.existsSync(this.path) === false) {
  221
+            docpad.log('info', "Updating " + this.name + "...");
  222
+            return balUtil.initOrPullGitRepo(balUtil.extend({
  223
+              remote: 'origin',
  224
+              branch: 'master',
  225
+              output: true,
  226
+              next: function(err) {
  227
+                if (err) {
  228
+                  docpad.warn(err);
  229
+                }
  230
+                docpad.log('info', "Updated " + _this.name);
  231
+                return complete();
229 232
               }
230  
-              docpad.log('info', "Updated Documentation");
231  
-              return complete();
232  
-            }
233  
-          }, this));
  233
+            }, this));
  234
+          } else {
  235
+            return complete();
  236
+          }
234 237
         });
235 238
       }
236 239
       tasks.async();
38  app/src/docpad.coffee
@@ -264,30 +264,32 @@ docpadConfig =
264 264
 			docpad = @docpad
265 265
 			config = docpad.getConfig()
266 266
 			tasks = new balUtil.Group(next)
267  
-
268  
-			# Skip if we are doing a differential generate
269  
-			return next()  if opts.reset is false or 'development' in docpad.getEnvironments()
270  
-
271  
-			# Log
272  
-			docpad.log('info', "Updating Documentation...")
273  
-
274  
-			# Repos
275 267
 			repos =
276 268
 				'docpad-documentation':
  269
+					name: 'DocPad Documentation'
277 270
 					path: pathUtil.join(config.documentsPaths[0],'docs')
278 271
 					url: 'git://github.com/bevry/docpad-documentation.git'
  272
+
  273
+			# Cycle through the repos assigning each repo value to @ so it works asynchronously
279 274
 			for own repoKey,repoValue of repos
280 275
 				tasks.push repoValue, (complete) ->
281  
-					balUtil.initOrPullGitRepo(balUtil.extend({
282  
-						remote: 'origin'
283  
-						branch: 'master'
284  
-						output: true
285  
-						next: (err) ->
286  
-							# warn about errors, but don't let them kill execution
287  
-							docpad.warn(err)  if err
288  
-							docpad.log('info', "Updated Documentation")
289  
-							complete()
290  
-					},@))
  276
+					if opts.reset is true or fs.existsSync(@path) is false
  277
+						# Log
  278
+						docpad.log('info', "Updating #{@name}...")
  279
+
  280
+						# Init or Update
  281
+						balUtil.initOrPullGitRepo(balUtil.extend({
  282
+							remote: 'origin'
  283
+							branch: 'master'
  284
+							output: true
  285
+							next: (err) =>
  286
+								# warn about errors, but don't let them kill execution
  287
+								docpad.warn(err)  if err
  288
+								docpad.log('info', "Updated #{@name}")
  289
+								complete()
  290
+						},@))
  291
+					else
  292
+						complete()
291 293
 
292 294
 			# Fire
293 295
 			tasks.async()
2  package.json
@@ -24,7 +24,7 @@
24 24
 		"npm": "1.1.x"
25 25
 	},
26 26
 	"dependencies": {
27  
-		"docpad": "6.20.x",
  27
+		"docpad": "6.21.x",
28 28
 		"docpad-plugin-coffeekup": "2.x",
29 29
 		"docpad-plugin-coffeescript": "2.x",
30 30
 		"docpad-plugin-eco": "2.x",

0 notes on commit 69eb754

Please sign in to comment.
Something went wrong with that request. Please try again.