Skip to content
This repository
tree: 2125ba1f29
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 40 lines (34 sloc) 0.932 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
# 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 docpadConfig, (err,docpad) ->
# Check
return console.log(err.stack) if err

# Generate and Serve
docpad.action serverAction, (err) ->
# Check
return console.log(err.stack) if err

# Done
console.log('OK')
Something went wrong with that request. Please try again.