mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #31413 from BendingBender/trash
[trash] Allow only string/string[] as paths, export Options interface
This commit is contained in:
Vendored
+13
-4
@@ -2,12 +2,21 @@
|
||||
// Project: https://github.com/sindresorhus/trash#readme
|
||||
// Definitions by: Matthew James <https://github.com/matthew-matvei>
|
||||
// Keiichiro Amemiya <https://github.com/hoishin>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface TrashOptions {
|
||||
glob: boolean;
|
||||
/**
|
||||
* Move files and folders to the trash
|
||||
*
|
||||
* @param paths Accepts paths and [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
* @param options.glob Enable globbing when matching file paths
|
||||
*/
|
||||
declare function trash(paths: string | string[], options?: trash.Options): Promise<void>;
|
||||
|
||||
declare namespace trash {
|
||||
interface Options {
|
||||
glob: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare function trash(iterable: Iterable<string>, opts?: TrashOptions): Promise<void>;
|
||||
|
||||
export = trash;
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import trash = require("trash");
|
||||
import trash = require('trash');
|
||||
|
||||
async function testTrashNoArgs() {
|
||||
await trash(["/path/to/item1", "/path/to/item2"]);
|
||||
async function testTrashNoArgsSinglePath() {
|
||||
await trash('/path/to/item1');
|
||||
}
|
||||
|
||||
async function testTrashNoArgsMultiPath() {
|
||||
await trash(['/path/to/item1', '/path/to/item2']);
|
||||
}
|
||||
|
||||
async function testTrashWithArgs() {
|
||||
await trash(["/path/to/item1", "/path/to/item2"], { glob: false });
|
||||
const options: trash.Options = { glob: false };
|
||||
await trash(['/path/to/item1', '/path/to/item2'], options);
|
||||
}
|
||||
|
||||
async function testTrashPerDocumentation() {
|
||||
trash(["*.png", "!rainbow.png"]).then(() => {
|
||||
console.log("done");
|
||||
});
|
||||
function testTrashPerDocumentation() {
|
||||
(async () => {
|
||||
await trash(['*.png', '!rainbow.png']);
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
"es6"
|
||||
],
|
||||
"target": "es2015",
|
||||
"noImplicitAny": true,
|
||||
@@ -22,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"trash-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user