From 4ead81cc68ab1a2cd824de4394e1bda72b1b9f92 Mon Sep 17 00:00:00 2001 From: Louis De Bevere Date: Sun, 14 Feb 2016 20:24:55 +0100 Subject: [PATCH] Improves typings for vinyl/vinyl-fs --- vinyl-fs/vinyl-fs-tests.ts | 11 +++++++++++ vinyl-fs/vinyl-fs.d.ts | 4 +++- vinyl/vinyl.d.ts | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/vinyl-fs/vinyl-fs-tests.ts b/vinyl-fs/vinyl-fs-tests.ts index c8ca090700..09758e053c 100644 --- a/vinyl-fs/vinyl-fs-tests.ts +++ b/vinyl-fs/vinyl-fs-tests.ts @@ -909,4 +909,15 @@ describe('symlink stream', function () { stream.end(); }); }); + it('should check if it"s a vinyl file', function () { + var srcPath = path.join(__dirname, './fixtures/test.coffee'); + var options = { + path: srcPath, + cwd: __dirname, + contents: new Buffer("1234567890") + }; + var file = new File(options); + File.isVinyl(file).should.equal(true); + File.isVinyl(options).should.equal(false); + }) }); diff --git a/vinyl-fs/vinyl-fs.d.ts b/vinyl-fs/vinyl-fs.d.ts index 70fc32abaa..e068132438 100644 --- a/vinyl-fs/vinyl-fs.d.ts +++ b/vinyl-fs/vinyl-fs.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// /// declare module NodeJS { @@ -15,8 +16,9 @@ declare module NodeJS { declare module "vinyl-fs" { import _events = require("events"); import File = require("vinyl"); + import globStream = require("glob-stream"); - interface ISrcOptions { + interface ISrcOptions extends globStream.Options { /** Specifies the working directory the folder is relative to */ cwd?: string; diff --git a/vinyl/vinyl.d.ts b/vinyl/vinyl.d.ts index 77bf252b7a..293ce51144 100644 --- a/vinyl/vinyl.d.ts +++ b/vinyl/vinyl.d.ts @@ -135,6 +135,11 @@ declare module "vinyl" { * Returns a pretty String interpretation of the File. Useful for console.log. */ public inspect(): string; + + /** + * Checks if a given object is a vinyl file. + */ + public static isVinyl(obj: any): boolean; } export = File;