From d54b01d5692a02c2932f231c29b022430b208a15 Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Wed, 28 Jan 2015 13:26:37 -0800 Subject: [PATCH] Adding a type definition for del This is useful for people who want to write their gulpfile in TypeScript. --- del/del-tests.ts | 28 ++++++++++++++++++++++++++++ del/del.d.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 del/del-tests.ts create mode 100644 del/del.d.ts diff --git a/del/del-tests.ts b/del/del-tests.ts new file mode 100644 index 0000000000..d2e931dfbf --- /dev/null +++ b/del/del-tests.ts @@ -0,0 +1,28 @@ +/// +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}); \ No newline at end of file diff --git a/del/del.d.ts b/del/del.d.ts new file mode 100644 index 0000000000..f83fb821b4 --- /dev/null +++ b/del/del.d.ts @@ -0,0 +1,28 @@ +// Type definitions for del +// Project: https://github.com/sindresorhus/del +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; +} \ No newline at end of file