From 6f8b61188d408c9496dea9109a74e2eef0f2b6c0 Mon Sep 17 00:00:00 2001 From: Thomas Vantuycom Date: Thu, 4 Jan 2018 11:59:26 +0100 Subject: [PATCH] Drop dependency on deprecated `gulp-util` Closes #30 --- index.js | 4 ++-- package.json | 7 ++++--- test/main.js | 32 ++++++++++++++++---------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index fe40c37..a16154e 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ var _ = require("lodash"); -var gutil = require("gulp-util"); +var replaceExtension = require('replace-ext'); var map = require("map-stream"); var TEMPLATES = { @@ -52,7 +52,7 @@ module.exports = function (options) { if(options && options.extension) { extension = options.extension; } - file.path = gutil.replaceExtension(file.path, extension); + file.path = replaceExtension(file.path, extension); } return callback(null, file); diff --git a/package.json b/package.json index 776920e..9b40e3c 100644 --- a/package.json +++ b/package.json @@ -25,14 +25,15 @@ "test": "mocha" }, "dependencies": { - "gulp-util": "*", "lodash": ">=3.3 <5", - "map-stream": "*" + "map-stream": "*", + "replace-ext": "^1.0.0" }, "devDependencies": { + "event-stream": "~3.0.20", "mocha": "~1.14.0", "should": "~2.1.0", - "event-stream": "~3.0.20" + "vinyl": "^2.1.0" }, "engines": { "node": ">=0.8.0", diff --git a/test/main.js b/test/main.js index 55a6964..7dfea45 100644 --- a/test/main.js +++ b/test/main.js @@ -6,13 +6,13 @@ var fs = require("fs"); var path = require("path"); var es = require("event-stream"); var should = require("should"); -var gutil = require("gulp-util"); +var Vinyl = require("vinyl"); var ngHtml2Js = require("../"); describe("gulp-ng-html2js", function () { describe("when file is provided via buffer", function () { it("should generate the angular module", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/example.js", cwd: "test/", base: "test/expected", @@ -24,7 +24,7 @@ describe("gulp-ng-html2js", function () { describe("when options.export is provided", function(){ it("commonjs", function(done){ - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithExportCommon.js", cwd: "test/", base: "test/expected", @@ -39,7 +39,7 @@ describe("gulp-ng-html2js", function () { }); it("should use common, options.moduleName && options.declareModule when provided", function(done){ - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithExportCommonModuleNameNoGenerate.js", cwd: "test/", base: "test/expected", @@ -56,7 +56,7 @@ describe("gulp-ng-html2js", function () { }); it("system", function(done){ - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithExportSystem.js", cwd: "test/", base: "test/expected", @@ -71,7 +71,7 @@ describe("gulp-ng-html2js", function () { }); it("should use system, options.moduleName && options.declareModule when provided", function(done){ - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithExportSystemModuleNameNoGenerate.js", cwd: "test/", base: "test/expected", @@ -89,7 +89,7 @@ describe("gulp-ng-html2js", function () { }); it("should use options.moduleName when provided", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithModuleName.js", cwd: "test/", base: "test/expected", @@ -104,7 +104,7 @@ describe("gulp-ng-html2js", function () { }); it("should use options.moduleName (function) when provided", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithModuleName.js", cwd: "test/", base: "test/expected", @@ -122,7 +122,7 @@ describe("gulp-ng-html2js", function () { }); it("should use options.moduleName && options.declareModule when provided", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithModuleNameNoGenerate.js", cwd: "test/", base: "test/expected", @@ -138,7 +138,7 @@ describe("gulp-ng-html2js", function () { }); it("should add options.prefix to the url in the generated file", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithPrefix.js", cwd: "test/", base: "test/expected", @@ -153,7 +153,7 @@ describe("gulp-ng-html2js", function () { }); it("should subtract options.stripPrefix from the url in the generated file", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithStripPrefix.js", cwd: "test/", base: "test/expected", @@ -168,7 +168,7 @@ describe("gulp-ng-html2js", function () { }); it("should allow a custom function to rename the generated file", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithRename.js", cwd: "test/", base: "test/expected", @@ -185,7 +185,7 @@ describe("gulp-ng-html2js", function () { }); it("should allow using a custom template", function (done) { - var expectedFile = new gutil.File({ + var expectedFile = new Vinyl({ path: "test/expected/exampleWithCustomTemplate.js", cwd: "test/", base: "test/expected", @@ -201,7 +201,7 @@ describe("gulp-ng-html2js", function () { function testBufferedFile(params, expectedFile, done) { - var srcFile = new gutil.File({ + var srcFile = new Vinyl({ path: "test/fixtures/example.html", cwd: "test/", base: "test", @@ -226,7 +226,7 @@ describe("gulp-ng-html2js", function () { }); it("should pass on files which are null", function (done) { - var srcFile = new gutil.File({ + var srcFile = new Vinyl({ path: "test/fixtures/example.html", cwd: "test/", base: "test/fixtures", @@ -245,7 +245,7 @@ describe("gulp-ng-html2js", function () { }); it("should error on stream", function (done) { - var srcFile = new gutil.File({ + var srcFile = new Vinyl({ path: "test/fixtures/example.html", cwd: "test/", base: "test/fixtures",