diff --git a/.gitignore b/.gitignore index 9d140f3..2a1206d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ npm-debug.log config.json +dist/ \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 95b0e4d..0c225d9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ var coffeelint = require('gulp-coffeelint'); var nodemon = require('gulp-nodemon'); var plumber = require("gulp-plumber"); var cache = require("gulp-cache"); +var coffee = require("gulp-coffee"); gulp.task('lint', function () { gulp.src(['**/*.coffee', '!node_modules/**/*']) @@ -19,6 +20,17 @@ gulp.task('lint', function () { .pipe(coffeelint.reporter()); }); +gulp.task('config', function() { + return gulp.src('config.json') + .pipe(gulp.dest('dist/')); +}); + +gulp.task("coffee", ['config'], function() { + return gulp.src("*.coffee") + .pipe(coffee()) + .pipe(gulp.dest("dist/")); +}); + gulp.task('develop', function () { nodemon({ script: 'index.coffee'}) .on('change', ['lint']); diff --git a/package.json b/package.json index 2a09f2a..4cca5d4 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,16 @@ "devDependencies": { "gulp": "^3.8.11", "gulp-cache": "^0.3.0", + "gulp-coffee": "^2.3.3", "gulp-coffeelint": "^0.5.0", "gulp-nodemon": "^2.0.4", "gulp-plumber": "^1.0.1" }, "dependencies": { - "amqplib": "^0.4.1", + "amqplib": "^0.5.1", "base64-url": "^1.2.1", "bluebird": "^2.9.10", "node-uuid": "^1.4.2", - "ws": "^1.1.1" + "ws": "^2.0.3" } } diff --git a/rabbit.coffee b/rabbit.coffee index c8ff634..078e1be 100644 --- a/rabbit.coffee +++ b/rabbit.coffee @@ -52,8 +52,6 @@ channels = do -> return pendingChannels[client_id] pendingChannels[client_id] = new Promise (resolve, reject) -> - delete pendingChannels[client_id] - if !chs[client_id] getConnection() .then (connection) -> connection.createChannel() @@ -63,7 +61,10 @@ channels = do -> else resolve(chs[client_id]) - return pendingChannels[client_id] + return pendingChannels[client_id].then (ch) -> + delete pendingChannels[client_id] + + return ch return { removeClient: removeClient