Skip to content

Instantly share code, notes, and snippets.

@dobesv
Forked from anonymous/gulpfile.js
Last active June 30, 2016 06:39
Show Gist options
  • Save dobesv/0175640a973bd5557ad3fcf982eb49f1 to your computer and use it in GitHub Desktop.
Save dobesv/0175640a973bd5557ad3fcf982eb49f1 to your computer and use it in GitHub Desktop.
Reproduce RegularExpression condition bug with new version of node (6.2.2)
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var del = require('del');
var merge = require('merge-stream');
var path = require('path');
var RevAll = require('gulp-rev-all');
var runSequence = require('run-sequence');
var os = require('os');
src = [
'temp.coffee',
'temp2.js'
];
gulp.task('js1', function() {
var isCoffeeScript = function(f) {
return /[.]coffee$/.test(f.path);
};
return gulp.src(src)
.pipe(plugins.sourcemaps.init())
.pipe(plugins.if(isCoffeeScript, plugins.coffee({ bare: true }).on('error', function(err) { console.log('CoffeeScript error', err)})))
.pipe(plugins.concat('js1.js'))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('js1'));
});
gulp.task('js2', function() {
var isCoffeeScript = /[.]coffee$/
return gulp.src(src)
.pipe(plugins.sourcemaps.init())
.pipe(plugins.if(isCoffeeScript, plugins.coffee({ bare: true }).on('error', function(err) { console.log('CoffeeScript error', err)})))
.pipe(plugins.concat('js2.js'))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('js2'));
});
# Here's what I get
$ gulp js1
(node:18894) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[23:32:22] Using gulpfile ~/PycharmProjects/gulp-if-temp/gulpfile.js
[23:32:22] Starting 'js1'...
[23:32:23] Finished 'js1' after 165 ms
23:32:23 ~/PycharmProjects/gulp-if-temp
$ gulp js2
(node:18909) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[23:32:24] Using gulpfile ~/PycharmProjects/gulp-if-temp/gulpfile.js
[23:32:24] Starting 'js2'...
CoffeeScript error { /home/dobes/PycharmProjects/gulp-if-temp/temp2.js:1:2: error: regular expressions cannot begin with *
/* This is a test */
^
location: { first_line: 0, first_column: 1, last_column: 1 },
toString: [Function],
code: '/* This is a test */\ng = 2\n\nexports = {\n g: g\n}',
filename: '/home/dobes/PycharmProjects/gulp-if-temp/temp2.js',
name: 'SyntaxError',
message: 'regular expressions cannot begin with *',
stack: '/home/dobes/PycharmProjects/gulp-if-temp/temp2.js:1:2: error: regular expressions cannot begin with *\n/\u001b[1;31m*\u001b[0m This is a test */\n\u001b[1;31m ^\u001b[0m',
showStack: false,
showProperties: true,
plugin: 'gulp-coffee' }
events.js:160
throw er; // Unhandled 'error' event
^
/home/dobes/PycharmProjects/gulp-if-temp/temp2.js:1:2: error: regular expressions cannot begin with *
/* This is a test */
^
{
"name": "temp",
"version": "1.0.0",
"description": "",
"main": "",
"directories": {
"doc": "docs"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "..."
},
"author": "",
"license": "closed",
"devDependencies": {
"del": "^1.2.0",
"gulp": "^3.9.0",
"gulp-base64": "^0.1.3",
"gulp-coffee": "^2.3.1",
"gulp-concat": "^2.6.0",
"gulp-gzip": "^1.1.0",
"gulp-if": "^1.2.5",
"gulp-load-plugins": "^1.0.0-rc.1",
"gulp-rev-all": "^0.8.21",
"gulp-sass": "^2.0.3",
"gulp-shell": "^0.4.2",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglify": "^1.2.0",
"merge-stream": "^0.1.7",
"run-sequence": "^1.1.1"
}
}
# This is a test
f = 1
exports = {
f: f
}
/* This is a test */
g = 2
exports = {
g: g
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment