Skip to content

Instantly share code, notes, and snippets.

@Raynos
Last active January 2, 2016 01:29
Show Gist options
  • Save Raynos/8230415 to your computer and use it in GitHub Desktop.
Save Raynos/8230415 to your computer and use it in GitHub Desktop.
var task = require("monk")
var shell = require("monk-shell")
var buildTask = task("build", function (rule) {
rule("hello.c", "hello.o",
shell("gcc -Wall -c %i -o %o"))
rule("square.c", "square.o",
shell("gcc -Wall -c %i -o %o"))
rule(["hello.o", "square.o"], "hello",
shell("gcc %i -o %o"))
})
module.exports = buildTask
if (require.main === module) {
buildTask()
}
var exec = require("child_process").exec
module.exports = shell
function shell(command) {
return function (input, output, callback) {
var cmd = command.replace("%i", input).replace("%o", output)
exec(cmd, function (err, stdout, stderr) {
callback(err)
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment