Adding a type definition for del

This is useful for people who want to write their gulpfile in
TypeScript.
This commit is contained in:
Phips Peter
2015-01-28 13:26:37 -08:00
parent 338059f48e
commit d54b01d569
2 changed files with 56 additions and 0 deletions

28
del/del-tests.ts Normal file
View File

@@ -0,0 +1,28 @@
/// <reference path="./del.d.ts"/>
import del = require("del");
var paths = ["build", "dist/**/*.js"];
del(["tmp/*.js", "!tmp/unicorn.js"], (err, paths) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}, (err, paths) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del("tmp/*.js", (err, paths) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del("tmp/*.js", {force: true}, (err, paths) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del.sync(["tmp/*.js", "!tmp/unicorn.js"]);
del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
del.sync("tmp/*.js");
del.sync("tmp/*.js", {force: true});

28
del/del.d.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
// Type definitions for del
// Project: https://github.com/sindresorhus/del
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../glob/glob.d.ts"/>
declare module "del" {
import glob = require("glob");
function Del(pattern: string, callback: (err: Error, deletedFiles: string[]) => any): void;
function Del(pattern: string, options: Del.Options, callback: (err: Error, deletedFiles: string[]) => any): void;
function Del(patterns: string[], callback: (err: Error, deletedFiles: string[]) => any): void;
function Del(patterns: string[], options: Del.Options, callback: (err: Error, deletedFiles: string[]) => any): void;
module Del {
function sync(pattern: string, options?: Options): void;
function sync(patterns: string[], options?: Options): void;
interface Options extends glob.IOptions {
force?: boolean
}
}
export = Del;
}