Null-safe property access (and conditional assignment) in ES6/2015

Is there a null-safe property access (null propagation / existence) operator in ES6 (ES2015/JavaScript.next/Harmony) like ?. in CoffeeScript for example? Or is it planned for ES7? var aThing = getSomething() … aThing = possiblyNull?.thing This will be roughly like: if (possiblyNull != null) aThing = possiblyNull.thing Ideally the solution should not assign (even undefined) to … Read more

Exec : display stdout “live”

I have this simple script : var exec = require(‘child_process’).exec; exec(‘coffee -cw my_file.coffee’, function(error, stdout, stderr) { console.log(stdout); }); where I simply execute a command to compile a coffee-script file. But stdout never get displayed in the console, because the command never ends (because of the -w option of coffee). If I execute the command … Read more

How to run Gulp tasks sequentially one after the other

in the snippet like this: gulp.task “coffee”, -> gulp.src(“src/server/**/*.coffee”) .pipe(coffee {bare: true}).on(“error”,gutil.log) .pipe(gulp.dest “bin”) gulp.task “clean”,-> gulp.src(“bin”, {read:false}) .pipe clean force:true gulp.task ‘develop’,[‘clean’,’coffee’], -> console.log “run something else” In develop task I want to run clean and after it’s done, run coffee and when that’s done, run something else. But I can’t figure that out. … Read more

How to use executables from a package installed locally in node_modules?

How do I use a local version of a module in node.js. For example, in my app, I installed coffee-script: npm install coffee-script This installs it in ./node_modules and the coffee command is in ./node_modules/.bin/coffee. Is there a way to run this command when I’m in my project’s main folder? I guess I’m looking for … Read more

Why doesn’t adding CORS headers to an OPTIONS route allow browsers to access my API?

I am trying to support CORS in my Node.js application that uses the Express.js web framework. I have read a Google group discussion about how to handle this, and read a few articles about how CORS works. First, I did this (code is written in CoffeeScript syntax): app.options “*”, (req, res) -> res.header ‘Access-Control-Allow-Origin’, ‘*’ … Read more