Created
March 26, 2014 17:00
-
-
Save mach3/9788084 to your computer and use it in GitHub Desktop.
Grunt task to run php built-in server
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
/** | |
* Grunt Task : phps | |
* ----------------- | |
* Run php built-in server | |
*/ | |
module.exports = function(grunt) { | |
grunt.registerMultiTask("phps", "", function() { | |
var exec, cmd, options; | |
exec = require("child_process").exec; | |
options = this.options({ | |
port: 8080, | |
host: "localhost", | |
base: "./", | |
keepalive: false, | |
router: null | |
}); | |
cmd = grunt.template.process( | |
"php -S <%=host %>:<%=port %> -t <%=base %> <%=router %>", { | |
data: options | |
} | |
); | |
if (options.keepalive) { | |
this.async(); | |
} | |
exec(cmd); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment