Created
February 28, 2015 19:58
-
-
Save danihodovic/36d2666ec10f6bf40fad to your computer and use it in GitHub Desktop.
Gulp + Tsc without wrappers
This file contains 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
gulp.task('main', function () { | |
native_tsc_task(d_src, d_out, js_out) | |
}) | |
var spawn = require('child_process').spawn | |
function native_tsc_task(main_file, out_file, out_dir) { | |
var child = spawn('tsc', [main_file, '--out', out_dir + out_file, '--target', 'es5', '--noEmitOnError', '--sourceMap']) | |
var child_output = '' | |
child.stdout.on('data', function(data) { child_output += data.toString() } ) | |
child.stdout.on('end', function(data) { handle_tsc_output(main_file, child_output) } ) | |
} | |
var error_regex = new RegExp('error', 'i') | |
function handle_tsc_output(filename, str) { | |
var title = filename | |
var msg = '' | |
var error = error_regex.test(str) | |
if(error) { | |
var strs = str.split('\n') | |
title += ' Error' | |
msg = strs[1] | |
console.log(msg) | |
} | |
else { | |
title += ' Success' | |
livereload() | |
} | |
notifier.notify({ | |
title: title, | |
message: msg.substr(0, 281) + "..." | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment