Add typings for rmfr

This commit is contained in:
Alan Plum
2018-05-15 17:15:27 +02:00
parent d11cc3b1a2
commit 2cdf91a8b3
4 changed files with 73 additions and 0 deletions

17
types/rmfr/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for rmfr 2.0
// Project: https://github.com/shinnn/rmfr#readme
// Definitions by: Alan Plum <https://github.com/pluma>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import rimraf = require("rimraf");
declare namespace rmfr {
type Options = rimraf.Options & {
glob?: rimraf.Options["glob"] | true;
disableGlob?: never;
};
}
declare function rmfr(path: string, options?: rmfr.Options): Promise<void>;
export = rmfr;

39
types/rmfr/rmfr-tests.ts Normal file
View File

@@ -0,0 +1,39 @@
import rmfr = require("rmfr");
(async () => {
// happy
await rmfr("tmp_file");
await rmfr("tmp_d*", {});
await rmfr("../{tmp_d*,test.js}", {
glob: {
cwd: "node_modules",
ignore: "some_filename"
}
});
await rmfr("test.js", {
glob: {
cwd: "this/directory/does/not/exist"
}
});
// $ExpectError
await rmfr(".gitignore", { unlink: (path, cb) => cb(new Error()) });
// $ExpectError
await rmfr();
// $ExpectError
await rmfr("<", { o: "O" }, "/");
// $ExpectError
await rmfr(["1"], { glob: true });
// $ExpectError
await rmfr("foo", 1);
// $ExpectError
await rmfr("foo", { chmod: new Set(["a"]) });
// $ExpectError
await rmfr("foo", {
maxBusyTries: "foo",
emfileWait: "bar",
glob: "baz"
});
// $ExpectError
await rmfr("foo", { disableGlob: true });
})();

16
types/rmfr/tsconfig.json Normal file
View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "rmfr-tests.ts"]
}

1
types/rmfr/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }