diff --git a/types/move-concurrently/index.d.ts b/types/move-concurrently/index.d.ts new file mode 100644 index 0000000000..277c1299f1 --- /dev/null +++ b/types/move-concurrently/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for move-concurrently 1.0 +// Project: https://www.npmjs.com/package/move-concurrently +// Definitions by: Melvin Groenhoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/** + * Recursively moves from to to and resolves its promise when finished. If to already exists then the promise will be rejected with an EEXIST error. + */ +declare function move = Promise>(from: string, to: string, opts?: move.Options): T; + +declare namespace move { + interface Options = Promise> { + /** + * (Default: 1) The maximum number of concurrent copies to do at once. + */ + maxConcurrency?: number; + /** + * (Default: process.platform === 'win32') If true enables Windows symlink semantics. + * This requires an extra stat to determine if the destination of a symlink is a file or directory. + * If symlinking a directory fails then we'll try making a junction instead. + */ + isWindows?: boolean; + /** + * (Default: global.Promise) The promise implementation to use, defaults to Node's. + */ + Promise?: new (...args: any[]) => T; + /** + * (Default: require('fs')) The filesystem module to use. Can be used to use graceful-fs or to inject a mock. + */ + fs?: any; + /** + * (Default: require('fs-write-stream-atomic')) The implementation of writeStreamAtomic to use. Used to inject a mock. + */ + writeStreamAtomic?: any; + /** + * (Default: process.getuid) A function that returns the current UID. Used to inject a mock. + */ + getuid?: any; + } +} + +export = move; diff --git a/types/move-concurrently/move-concurrently-tests.ts b/types/move-concurrently/move-concurrently-tests.ts new file mode 100644 index 0000000000..47fc14272c --- /dev/null +++ b/types/move-concurrently/move-concurrently-tests.ts @@ -0,0 +1,20 @@ +import * as move from 'move-concurrently'; + +move('/path/to/thing', '/new/path/thing').then(() => { + // thing is now moved! +}).catch((err: any) => { + // oh no! +}); + +import * as Bluebird from 'bluebird'; + +const promise = move('/path/to/thing', '/new/path/thing', { Promise: Bluebird }) + .then(() => { + // thing is now moved! + }) + .error((err: any) => { + // this is a Bluebird promise! + }) + .catch((err: any) => { + // oh no! + }); diff --git a/types/move-concurrently/tsconfig.json b/types/move-concurrently/tsconfig.json new file mode 100644 index 0000000000..732b0ac5d0 --- /dev/null +++ b/types/move-concurrently/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "move-concurrently-tests.ts" + ] +} diff --git a/types/move-concurrently/tslint.json b/types/move-concurrently/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/move-concurrently/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }