UNPKG

3.93 kBTypeScriptView Raw
1// Type definitions for gulp-util 3.0
2// Project: https://github.com/gulpjs/gulp-util
3// Definitions by: jedmao <https://github.com/jedmao>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/// <reference types="node" />
7
8import vinyl = require('vinyl');
9import chalk from 'chalk';
10import through2 = require('through2');
11
12export { vinyl as File };
13
14/**
15 * Replaces a file extension in a path. Returns the new path.
16 */
17export function replaceExtension(npath: string, ext: string): string;
18
19export const colors: typeof chalk;
20
21export const date: {
22 (now?: Date | string, mask?: string, convertLocalTimeToUTC?: boolean): any;
23 masks: any;
24};
25
26/**
27 * Logs stuff. Already prefixed with [gulp] and all that. Use the right colors
28 * for values. If you pass in multiple arguments it will join them by a space.
29 */
30export function log(message?: any, ...optionalParams: any[]): void;
31
32/**
33 * This is a lodash.template function wrapper. You must pass in a valid gulp
34 * file object so it is available to the user or it will error. You can not
35 * configure any of the delimiters. Look at the lodash docs for more info.
36 */
37export function template(tmpl: string): (opt: { file: { path: string } }) => string;
38export function template(tmpl: string, opt: { file: { path: string } }): string;
39
40export const env: any;
41
42export function beep(): void;
43
44/**
45 * Returns a stream that does nothing but pass data straight through.
46 */
47export const noop: typeof through2;
48
49export function isStream(obj: any): boolean;
50
51export function isBuffer(obj: any): boolean;
52
53export function isNull(obj: any): boolean;
54
55export const linefeed: string;
56
57export function combine(streams: NodeJS.ReadWriteStream[]): () => NodeJS.ReadWriteStream;
58export function combine(...streams: NodeJS.ReadWriteStream[]): () => NodeJS.ReadWriteStream;
59
60/**
61 * This is similar to es.wait but instead of buffering text into one string
62 * it buffers anything into an array (so very useful for file objects).
63 */
64export function buffer(cb?: (err: Error, data: any[]) => void): NodeJS.ReadWriteStream;
65
66export class PluginError implements Error, PluginErrorOptions {
67 constructor(options?: PluginErrorOptions);
68 constructor(pluginName: string, options?: PluginErrorOptions);
69 constructor(pluginName: string, message: string | Error, options?: PluginErrorOptions);
70 /**
71 * The module name of your plugin.
72 */
73 name: string;
74 /**
75 * Can be a string or an existing error.
76 */
77 message: any;
78 fileName: string;
79 lineNumber: number;
80 /**
81 * You need to include the message along with this stack. If you pass an
82 * error in as the message the stack will be pulled from that, otherwise one
83 * will be created.
84 */
85 stack: string;
86 /**
87 * By default the stack will not be shown. Set this to true if you think the
88 * stack is important for your error.
89 */
90 showStack: boolean;
91 /**
92 * Error properties will be included in err.toString(). Can be omitted by
93 * setting this to false.
94 */
95 showProperties: boolean;
96 plugin: string;
97 error: Error;
98}
99
100export interface PluginErrorOptions {
101 /**
102 * The module name of your plugin.
103 */
104 name?: string;
105 /**
106 * Can be a string or an existing error.
107 */
108 message?: any;
109 fileName?: string;
110 lineNumber?: number;
111 /**
112 * You need to include the message along with this stack. If you pass an
113 * error in as the message the stack will be pulled from that, otherwise one
114 * will be created.
115 */
116 stack?: string;
117 /**
118 * By default the stack will not be shown. Set this to true if you think the
119 * stack is important for your error.
120 */
121 showStack?: boolean;
122 /**
123 * Error properties will be included in err.toString(). Can be omitted by
124 * setting this to false.
125 */
126 showProperties?: boolean;
127 plugin?: string;
128 error?: Error;
129}