Skip to content

Instantly share code, notes, and snippets.

@sintaxi
Last active October 20, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sintaxi/5aefdc6f4169633a5cee to your computer and use it in GitHub Desktop.
Save sintaxi/5aefdc6f4169633a5cee to your computer and use it in GitHub Desktop.
Example surge CLI integration
/**
* Surge Integration
*/
var surge = require('surge')({ platform: "harpjs.com" })
var hooks = {
postProject: function(req, next){
tmp.dir(function(err, outputPath, cleanupCallback) {
harp.compile(req.project, outputPath, function(errors, output){
if(errors) {
console.log(errors)
process.exit(1)
} else {
req.src = req.project
req.project = outputPath
next()
}
})
})
},
postPublish: function(req, next){
fse.remove(req.project, function(){
next()
})
}
}
program
.command("publish")
.description("publish to the web instantly")
.action(surge.actions.publish(hooks))
program
.command("whoami")
.description("check who currently logged in as")
.action(surge.actions.whoami())
program
.command("login")
.description("authenticate")
.action(surge.actions.login())
program
.command("logout")
.description("authenticate")
.action(surge.actions.logout())
program
.command("help")
.description("this help message")
.action(function(){
console.log("custom help message")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment