diff --git a/.gitignore b/.gitignore index d3f11de..bdaa3f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ # https://help.github.com/articles/ignoring-files # Example .gitignore files: https://github.com/github/gitignore /bower_components/ -/node_modules/ \ No newline at end of file +/node_modules/ +/lib/ diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..a754bca --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,73 @@ +var gulp = require("gulp"); +var psTree = require("ps-tree"); +var nodemon = require("gulp-nodemon"); +var presetES2015 = require("@joepie91/gulp-preset-es2015"); + +var source = ["src/**/*.js"]; + +/* The following resolves JacksonGariety/gulp-nodemon#33 */ +process.once("SIGINT", function() { + process.exit(0); +}); + +/* The following resolves remy/nodemon#34 */ +function cleanupChildren(cb) { + psTree(process.pid, function(err, children) { + children.filter(function(child) { + return (child.PPID === process.pid.toString() && child.COMMAND === "node"); + }).forEach(function(child) { + killChildren(children, child.PID); + }); + + cb(); + }); +} + +function killChildren(children, pid) { + children.forEach(function(child) { + if (child.PPID === pid) { + killChildren(children, child.PID); + } + }); + + console.error("Killing child Node.js process:", pid); + process.kill(parseInt(pid)); +} + +process.once("uncaughtException", function(err) { + console.log(err.stack || err); + + cleanupChildren(function() { + process.exit(1); + }); +}) + + +gulp.task('babel', function() { + return gulp.src(source) + .pipe(presetES2015({ + basePath: __dirname + })) + .pipe(gulp.dest("lib/")); +}); + +gulp.task("watch", function () { + gulp.watch(source, ["babel"]); +}); + + +gulp.task("nodemon", ["babel"], function() { + return nodemon({ + script: "lib/index.js", + ignore: [ + "gulpfile.js", + "node_modules" + ] + }); +}); + +gulp.task("watch", ["nodemon"], function() { + gulp.watch(source, ["babel"]) +}); + +gulp.task('default', ["watch"]); diff --git a/package.json b/package.json new file mode 100644 index 0000000..23e4d22 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "ircbullshit-proxy", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git@git.cryto.net:orgBullshit/ircBullshit-proxy.git" + }, + "author": "", + "license": "WTFPL", + "devDependencies": { + "@joepie91/gulp-preset-es2015": "^1.0.1", + "babel-preset-es2015": "^6.9.0", + "gulp": "^3.9.1", + "gulp-nodemon": "^2.1.0", + "ps-tree": "^1.1.0" + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..60a7cb0 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +'use strict'; + +// Application entry point goes here... + +console.log("Hello world!"); \ No newline at end of file