diff --git a/index.js b/index.js index b82001b..b087668 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,8 @@ var fs = require('fs'), path = require('path'), es = require('event-stream'), - gutil = require('gulp-util'), + PluginError = require('plugin-error'), + colors = require('ansi-colors'), glob = require('glob'), applySourceMap = require('vinyl-sourcemaps-apply'), stripBom = require('strip-bom'); @@ -43,7 +44,7 @@ module.exports = function (params) { } if (file.isStream()) { - throw new gutil.PluginError('gulp-include', 'stream not supported'); + throw new PluginError('gulp-include', 'stream not supported'); } if (file.isBuffer()) { @@ -281,11 +282,11 @@ module.exports = function (params) { function fileNotFoundError(includePath) { if (hardFail) { - throw new gutil.PluginError('gulp-include', 'No files found matching ' + includePath); + throw new PluginError('gulp-include', 'No files found matching ' + includePath); }else{ console.warn( - gutil.colors.yellow('WARN: ') + - gutil.colors.cyan('gulp-include') + + colors.yellow('WARN: ') + + colors.cyan('gulp-include') + ' - no files found matching ' + includePath ); } diff --git a/package.json b/package.json index 475be89..c416b41 100644 --- a/package.json +++ b/package.json @@ -20,15 +20,17 @@ "license": "MIT", "devDependencies": { "gulp": "~3.3.4", + "gulp-sourcemaps": "^1.1.4", "mocha": "~1.17.0", "should": "~2.1.1", - "gulp-sourcemaps": "^1.1.4", - "stream-assert": "^2.0.1" + "stream-assert": "^2.0.1", + "vinyl": "^2.1.0" }, "dependencies": { + "ansi-colors": "^1.0.1", "event-stream": "~3.1.0", "glob": "^5.0.12", - "gulp-util": "~2.2.10", + "plugin-error": "^0.1.2", "source-map": "^0.5.1", "strip-bom": "^2.0.0", "vinyl-sourcemaps-apply": "^0.2.0" diff --git a/test/main.js b/test/main.js index 323d65f..926ff8a 100644 --- a/test/main.js +++ b/test/main.js @@ -1,4 +1,4 @@ -var gutil = require("gulp-util"), +var Vinyl = require('vinyl'), should = require("should"), include = require("../index"), fs = require("fs"), @@ -13,7 +13,7 @@ var gutil = require("gulp-util"), describe("gulp-include", function () { describe("File including", function () { it("should replace special comments with file contents", function (done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/basic-include.js", contents: fs.readFileSync("test/fixtures/js/basic-include.js") @@ -31,7 +31,7 @@ describe("gulp-include", function () { }); it("should keep whitespace when including", function (done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/whitespace.js", contents: fs.readFileSync("test/fixtures/js/whitespace.js") @@ -49,7 +49,7 @@ describe("gulp-include", function () { }); it("should include complex folder trees", function (done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/include-trees.js", contents: fs.readFileSync("test/fixtures/js/include-trees.js") @@ -68,7 +68,7 @@ describe("gulp-include", function () { }) it("should not REQUIRE a file twice", function (done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/big-dummy-project-file.js", contents: fs.readFileSync("test/fixtures/js/big-dummy-project-file.js") @@ -86,7 +86,7 @@ describe("gulp-include", function () { }); it("should pull files recursively", function (done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/recursive.js", contents: fs.readFileSync("test/fixtures/js/recursive.js") @@ -104,7 +104,7 @@ describe("gulp-include", function () { }); it("should only include files with the set extensions, if provided", function (done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/options-extensions.js", contents: fs.readFileSync("test/fixtures/js/options-extensions.js") @@ -124,7 +124,7 @@ describe("gulp-include", function () { }); it("should work with html-comments", function(done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/html/basic-include.html", contents: fs.readFileSync("test/fixtures/html/basic-include.html") @@ -155,7 +155,7 @@ describe("gulp-include", function () { }); it('should strip unicode byte order marks from included files', function (done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/html/basic-include-with-unicode-BOM.html", contents: fs.readFileSync("test/fixtures/html/basic-include-with-unicode-BOM.html") @@ -174,7 +174,7 @@ describe("gulp-include", function () { }) it("should include from set includePaths", function(done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/include-path.js", contents: fs.readFileSync("test/fixtures/js/include-path.js") @@ -198,7 +198,7 @@ describe("gulp-include", function () { }) it("should throw an error if no match is found with hardFail: true", function(done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/include-fail.js", contents: fs.readFileSync("test/fixtures/js/include-fail.js") @@ -214,7 +214,7 @@ describe("gulp-include", function () { }) it("should not throw an error if no match is found with hardFail: false", function(done) { - var file = new gutil.File({ + var file = new Vinyl({ base: "test/fixtures/", path: "test/fixtures/js/include-fail.js", contents: fs.readFileSync("test/fixtures/js/include-fail.js")