Skip to content
Merged
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
45 changes: 45 additions & 0 deletions types/gulp-ttf2woff2/gulp-ttf2woff2-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import gulp = require('gulp');
import ttf2woff2 = require('gulp-ttf2woff2');
import PluginError = require('plugin-error');

gulp.task('ttf2woff2', () => {
gulp.src(['fonts/*.ttf']).pipe(ttf2woff2()).pipe(gulp.dest('fonts/'));
});

ttf2woff2({});

ttf2woff2({
ignoreExt: true,
});

ttf2woff2({
clone: true,
});

ttf2woff2({
ignoreExt: true,
clone: true,
});

const fileTransform = ttf2woff2.fileTransform();

declare const err1: TypeError | null;
declare const buf1: Buffer | undefined;
declare const transformResult1: (err: PluginError | null, buf: Buffer | undefined) => string | undefined;

// $ExpectType string | undefined
fileTransform(err1, buf1, transformResult1);

declare const err2: TypeError;
declare const buf2: undefined;
declare const transformResult2: (err: PluginError | null, buf: Buffer | undefined) => void;

// $ExpectType void
fileTransform(err2, buf2, transformResult2);

declare const err3: null;
declare const buf3: Buffer;
declare const transformeResult3: (err: PluginError | null, buf: Buffer | undefined) => string;

// $ExpectType string
fileTransform(err3, buf3, transformeResult3);
52 changes: 52 additions & 0 deletions types/gulp-ttf2woff2/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Type definitions for gulp-ttf2woff2 4.0
// Project: https://github.com/nfroidure/gulp-ttf2woff2
// Definitions by: Anatoly Pitikin <https://github.com/xapdkop>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node"/>

import PluginError = require('plugin-error');

declare namespace ttf2woff2 {
interface Options {
/**
* Also convert files that doesn't have the .ttf extension.
*/
ignoreExt?: boolean;

/**
* Clone the file before converting him so that it will output the original file too.
*/
clone?: boolean;
}

/**
* Callback function handling the buffered content
*/
type FileTransformCallback = <TResult, TError>(
err: TError | null,
buf: Buffer | undefined,
cb: (err: PluginError<TError> | PluginError<Error> | null, buf: Buffer | undefined) => TResult,
) => TResult;

/**
* File level transform function (for use by other plugins)
*/
function fileTransform(): FileTransformCallback;
}

/**
* Create a WOFF2 font from a TTF font with Gulp
*
* @example
* const ttf2woff2 = require('gulp-ttf2woff2');
*
* gulp.task('ttf2woff2', function(){
* gulp.src(['fonts/*.ttf'])
* .pipe(ttf2woff2())
* .pipe(gulp.dest('fonts/'));
* });
*/
declare function ttf2woff2(options?: ttf2woff2.Options): NodeJS.ReadWriteStream;

export = ttf2woff2;
6 changes: 6 additions & 0 deletions types/gulp-ttf2woff2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"plugin-error": "^1.0.1"
}
}
23 changes: 23 additions & 0 deletions types/gulp-ttf2woff2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gulp-ttf2woff2-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/gulp-ttf2woff2/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }