Fix del typings - Return promise rather instead of taking in a callback. #5908

This commit is contained in:
unknown 2015-10-06 22:09:12 +13:00
parent 05557455c4
commit 170bd06de4
2 changed files with 16 additions and 18 deletions

View File

@ -7,11 +7,11 @@ del(["tmp/*.js", "!tmp/unicorn.js"]);
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
del(["tmp/*.js", "!tmp/unicorn.js"], (err, paths) => {
del(["tmp/*.js", "!tmp/unicorn.js"]).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}, (err, paths) => {
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
@ -19,18 +19,19 @@ del("tmp/*.js");
del("tmp/*.js", {force: true});
del("tmp/*.js", (err, paths) => {
del("tmp/*.js").then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del("tmp/*.js", {force: true}, (err, paths) => {
del("tmp/*.js", {force: true}).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del.sync(["tmp/*.js", "!tmp/unicorn.js"]);
var paths: string[];
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"]);
del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
del.sync("tmp/*.js");
paths = del.sync("tmp/*.js");
del.sync("tmp/*.js", {force: true});
paths = del.sync("tmp/*.js", {force: true});

17
del/del.d.ts vendored
View File

@ -4,23 +4,20 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../glob/glob.d.ts"/>
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module "del" {
import glob = require("glob");
function Del(pattern: string): void;
function Del(pattern: string, options: Del.Options): void;
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(pattern: string): Promise<string[]>;
function Del(pattern: string, options: Del.Options): Promise<string[]>;
function Del(patterns: string[]): void;
function Del(patterns: string[], options: Del.Options): 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;
function Del(patterns: string[]): Promise<string[]>;
function Del(patterns: string[], options: Del.Options): Promise<string[]>;
module Del {
function sync(pattern: string, options?: Options): void;
function sync(patterns: string[], options?: Options): void;
function sync(pattern: string, options?: Options): string[];
function sync(patterns: string[], options?: Options): string[];
interface Options extends glob.IOptions {
force?: boolean