Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Introduce Node.js 6+ compatibility mode for gulp@3 #1760

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

// Initialize vinyl-fs-wrap in Node.js 6+ compatibility mode
var vfsWrap = require('./vinyl-fs-wrap');
vfsWrap.initCompat();

// Export the origial Gulp
module.exports = require('./index');
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ var util = require('util');
var Orchestrator = require('orchestrator');
var gutil = require('gulp-util');
var deprecated = require('deprecated');
var vfs = require('vinyl-fs');

var vfsWrap = require('./vinyl-fs-wrap');
vfsWrap.init();
var vfs = vfsWrap.vfs;

function Gulp() {
Orchestrator.call(this);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"semver": "^4.1.0",
"tildify": "^1.0.0",
"v8flags": "^2.0.2",
"vinyl-fs": "^0.3.0"
"vinyl-fs": "^0.3.0",
"vinyl-fs-03-compat": "^0.3.15"
},
"devDependencies": {
"coveralls": "^2.7.0",
Expand Down
30 changes: 30 additions & 0 deletions vinyl-fs-wrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var compat = false;

function init() {
if (exports.vfs) {
return;
}
exports.vfs = require('vinyl-fs');
}

function initCompat() {
if (exports.vfs) {
if (!compat) {
throw new Error(
'Gulp was already initialized without Node.js 6+ compatibility mode!\n' +
'Make sure that you require gulp/compat before other gulp plugins.\n' +
'\n' +
'Note that dependencies should not force this mode.\n' +
'The compatibility mode is intended only for the top-most gulpfile.js.\n'
);
}
return;
}
compat = true;
exports.vfs = require('vinyl-fs-03-compat');
}

exports.init = init;
exports.initCompat = initCompat;