Merge pull request #31413 from BendingBender/trash

[trash] Allow only string/string[] as paths, export Options interface
This commit is contained in:
Nathan Shively-Sanders
2018-12-18 13:30:00 -08:00
committed by GitHub
3 changed files with 28 additions and 15 deletions
+13 -4
View File
@@ -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;
+13 -8
View File
@@ -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 -3
View File
@@ -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"
]
}
}