Skip to content

Commit

Permalink
Add definition for del (flow-typed#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
callumlocke authored and gantoine committed Nov 8, 2017
1 parent 56b4548 commit 77852b4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
47 changes: 47 additions & 0 deletions definitions/npm/del_v3.x.x/flow_v0.25.x-/del_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
type $npm$del$Patterns = string[] | string;

type $npm$del$Options = {
force?: boolean,
dryRun?: boolean,
concurrency?: number,

// remaining options are passed through to node-glob:
cwd?: string,
root?: string,
dot?: boolean,
nomount?: boolean,
mark?: boolean,
nosort?: boolean,
stat?: boolean,
silent?: boolean,
strict?: boolean,
cache?: Object,
statCache?: Object,
symlinks?: Object,
realpathCache?: Object,
nounique?: boolean,
nonull?: boolean,
debug?: boolean,
nobrace?: boolean,
noglobstar?: boolean,
noext?: boolean,
nocase?: boolean,
matchBase?: boolean,
nodir?: boolean,
ignore?: string | string[],
follow?: boolean,
realpath?: boolean,
absolute?: boolean
};

declare module "del" {
declare class Del {
(
patterns: $npm$del$Patterns,
options?: $npm$del$Options
): Promise<string[]>,
sync(patterns: $npm$del$Patterns, options?: $npm$del$Options): string[]
}

declare module.exports: Del;
}
19 changes: 19 additions & 0 deletions definitions/npm/del_v3.x.x/test_del_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const del = require("del");

del("**/.DS_Store").then((x: string[]) => {});

del(["foo", "bar"]).then((x: string[]) => {});

del(["../../foo/**"], {
force: true
}).then((x: string[]) => {});

(del.sync("**/.DS_Store"): string[]);

(del.sync(["foo", "bar"]): string[]);

// $ExpectError
del(123);

// $ExpectError
del.sync(123);

0 comments on commit 77852b4

Please sign in to comment.