Last active
October 20, 2015 00:09
-
-
Save sintaxi/5aefdc6f4169633a5cee to your computer and use it in GitHub Desktop.
Example surge CLI integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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