Permalink
Browse files

v6.7.4. Improvement.

- v6.7.4 October 10, 2012
	- `PORT` environment variable now comes before infrastructure specific
port variables
	- Can now do `docpad-server --action generate,server,watch --port 8080`
  • Loading branch information...
1 parent 3847877 commit 2125ba1f29cd8fcd3b9859cea601439c34093c11 @balupton balupton committed Oct 10, 2012
Showing with 40 additions and 13 deletions.
  1. +4 −0 History.md
  2. +1 −1 package.json
  3. +26 −4 src/bin/docpad-server.coffee
  4. +2 −2 src/lib/docpad.coffee
  5. +7 −6 src/test/actions.test.coffee
View
@@ -1,5 +1,9 @@
## History
+- v6.7.4 October 10, 2012
+ - `PORT` environment variable now comes before infrastructure specific port variables
+ - Can now do `docpad-server --action generate,server,watch --port 8080`
+
- v6.7.3 October 8, 2012
- Fixed logging when a fatal error occurs during initialisation
- We now do warnings when plugins do invalid naming conventions
View
@@ -1,6 +1,6 @@
{
"name": "docpad",
- "version": "6.7.3",
+ "version": "6.7.4",
"description": "DocPad is a language agnostic document management system. This means you write your website as documents, in whatever language you wish, and DocPad will handle the compiling, templates and layouts for you. For static documents it will generate static files, for dynamic documents it'll re-render them on each request. You can utilise DocPad by itself, or use it as a module your own custom system. It's pretty cool, and well worth checking out. We love it.",
"homepage": "https://github.com/bevry/docpad",
"keywords": [
@@ -1,14 +1,36 @@
# Require
DocPad = require(__dirname+'/../lib/docpad')
+# DocPad Configuration
+docpadConfig = {}
+serverAction = process.env.DOCPAD_SERVER_ACTION or 'generate server'
+
+# --action <value>
+(->
+ actionArgumentIndex = process.argv.indexOf('--action')
+ if actionArgumentIndex isnt -1
+ serverAction = process.argv[actionArgumentIndex+1]
+)()
+
+# --port <value>
+(->
+ portArgument = null
+ portArgumentIndex = process.argv.indexOf('--port')
+ if portArgumentIndex isnt -1
+ portArgument = process.argv[portArgumentIndex+1]
+ if isNaN(portArgument)
+ portArgument = null
+ else
+ portArgument = parseInt(portArgument,10)
+ if portArgument
+ docpadConfig.port = portArgument
+)()
+
# Create DocPad Instance
-DocPad.createInstance (err,docpad) ->
+DocPad.createInstance docpadConfig, (err,docpad) ->
# Check
return console.log(err.stack) if err
- # Fetch the server action
- serverAction = process.env.DOCPAD_SERVER_ACTION or 'generate server'
-
# Generate and Serve
docpad.action serverAction, (err) ->
# Check
@@ -543,10 +543,10 @@ class DocPad extends EventEmitterEnhanced
# Port
# The port that the server should use
+ # PORT - Heroku, Nodejitsu, Custom
# VCAP_APP_PORT - AppFog
# VMC_APP_PORT - CloudFoundry
- # PORT - Heroku, Nodejitsu
- port: process.env.VCAP_APP_PORT ? process.env.VMC_APP_PORT ? process.env.PORT ? 9778
+ port: process.env.PORT ? process.env.VCAP_APP_PORT ? process.env.VMC_APP_PORT ? 9778
# Max Age
# The caching time limit that is sent to the client
@@ -111,12 +111,6 @@ joe.suite 'docpad-actions', (suite,test) ->
)
)
- suite 'server', (suite,test) ->
-
- test 'server action', (done) ->
- docpad.action 'server', (err) ->
- done(err)
-
test 'ignored "ignored" documents"', (done) ->
balUtil.exists "#{outPath}/ignored.html", (exists) ->
expect(exists).to.be.false
@@ -127,7 +121,14 @@ joe.suite 'docpad-actions', (suite,test) ->
expect(exists).to.be.false
done()
+ suite 'server', (suite,test) ->
+
+ test 'server action', (done) ->
+ docpad.action 'server', (err) ->
+ done(err)
+
test 'served generated documents', (done) ->
+ console.log("#{baseUrl}/html.html")
request "#{baseUrl}/html.html", (err,response,actual) ->
return done(err) if err
balUtil.readFile "#{outExpectedPath}/html.html", (err,expected) ->

0 comments on commit 2125ba1

Please sign in to comment.