mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
feat(mkdirp): upgrade mkdirp types to 1.0 (#42108)
* feat: upgrade mkdirp types to 1.0 * try adding a packagejson * bump * just remove it * pr feedback
This commit is contained in:
parent
4ace90950d
commit
b8fdb6e94d
13
types/mkdirp-promise/index.d.ts
vendored
13
types/mkdirp-promise/index.d.ts
vendored
@ -1,13 +0,0 @@
|
||||
// Type definitions for mkdirp-promise 5.0
|
||||
// Project: https://github.com/ahmadnassri/mkdirp-promise
|
||||
// Definitions by: Alan Plum <https://github.com/pluma>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import mkdirp = require("mkdirp");
|
||||
|
||||
declare function mkdirpPromise(
|
||||
path: string,
|
||||
opts?: mkdirp.Mode | mkdirp.Options
|
||||
): Promise<mkdirp.Made>;
|
||||
export = mkdirpPromise;
|
||||
@ -1,6 +0,0 @@
|
||||
import mkdirpPromise = require("mkdirp-promise");
|
||||
|
||||
(async () => {
|
||||
const path = await mkdirpPromise("hello");
|
||||
if (path) await mkdirpPromise(path, { mode: 123 });
|
||||
})();
|
||||
@ -1,16 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "mkdirp-promise-tests.ts"]
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
70
types/mkdirp/index.d.ts
vendored
70
types/mkdirp/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for mkdirp 0.5
|
||||
// Type definitions for mkdirp 1.0
|
||||
// Project: https://github.com/substack/node-mkdirp
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// mrmlnc <https://github.com/mrmlnc>
|
||||
@ -8,12 +8,30 @@
|
||||
|
||||
import fs = require('fs');
|
||||
|
||||
declare function mkdirp(dir: string, cb: (err: NodeJS.ErrnoException, made: mkdirp.Made) => void): void;
|
||||
declare function mkdirp(dir: string, opts: mkdirp.Mode | mkdirp.Options, cb: (err: NodeJS.ErrnoException, made: mkdirp.Made) => void): void;
|
||||
/**
|
||||
* Create a new directory and any necessary subdirectories at dir with octal
|
||||
* permission string `opts.mode`. If opts is a string or number, it will be
|
||||
* treated as the `opts.mode`. If opts.mode isn't specified, it defaults to
|
||||
* 0o777 & (~`process.umask()`).
|
||||
*
|
||||
* Promise resolves to first directory made that had to be created, or
|
||||
* undefined if everything already exists. Promise rejects if any errors are
|
||||
* encountered. Note that, in the case of promise rejection, some directories
|
||||
* may have been created, as recursive directory creation is not an atomic operation.
|
||||
* You can optionally pass in an alternate fs implementation by passing in
|
||||
* opts.fs.
|
||||
*
|
||||
* Your implementation should have `opts.fs.mkdir(path, opts, cb)` and
|
||||
* `opts.fs.stat(path, cb)`.
|
||||
*
|
||||
* You can also override just one or the other of mkdir and stat by passing in
|
||||
* `opts.stat` or `opts.mkdir`, or providing an fs option that only overrides one
|
||||
* of these.
|
||||
*/
|
||||
declare function mkdirp(dir: string, opts?: mkdirp.Mode | mkdirp.Options): Promise<string|undefined>;
|
||||
|
||||
declare namespace mkdirp {
|
||||
type Made = string | null;
|
||||
type Mode = number | string | null;
|
||||
type Mode = number | string | undefined;
|
||||
|
||||
interface FsImplementation {
|
||||
mkdir: typeof fs.mkdir;
|
||||
@ -35,6 +53,46 @@ declare namespace mkdirp {
|
||||
fs?: FsImplementationSync;
|
||||
}
|
||||
|
||||
function sync(dir: string, opts?: Mode | OptionsSync): Made;
|
||||
/**
|
||||
* Synchronously create a new directory and any necessary subdirectories at
|
||||
* dir with octal permission string `opts.mode`. If opts is a string or number,
|
||||
* it will be treated as the `opts.mode`. If `opts.mode` isn't specified, it
|
||||
* defaults to 0o777 & (~`process.umask()`).
|
||||
* You can optionally pass in an alternate fs implementation by passing in
|
||||
* `opts.fs`. Your implementation should have `opts.fs.mkdirSync(path, mode)`
|
||||
* and `opts.fs.statSync(path)`. You can also override just one or the other
|
||||
* of `mkdirSync` and `statSync` by passing in `opts.statSync` or `opts.mkdirSync`,
|
||||
* or providing an fs option that only overrides one of these.
|
||||
* @returns Returns the first directory that had to be created, or undefined if everything already exists.
|
||||
*/
|
||||
function sync(dir: string, opts?: Mode | Options): string|undefined;
|
||||
|
||||
/**
|
||||
* Use the manual implementation (not the native one). This is the default
|
||||
* when the native implementation is not available or the stat/mkdir
|
||||
* implementation is overridden.
|
||||
*/
|
||||
function manual(dir: string, opts?: Mode | Options): Promise<string|undefined>;
|
||||
|
||||
/**
|
||||
* Use the manual implementation (not the native one). This is the default
|
||||
* when the native implementation is not available or the stat/mkdir
|
||||
* implementation is overridden.
|
||||
*/
|
||||
function manualSync(dir: string, opts?: Mode | Options): string|undefined;
|
||||
|
||||
/**
|
||||
* Use the native implementation (not the manual one). This is the default
|
||||
* when the native implementation is available and stat/mkdir are not
|
||||
* overridden.
|
||||
*/
|
||||
function native(dir: string, opts?: Mode | Options): Promise<string|undefined>;
|
||||
|
||||
/**
|
||||
* Use the native implementation (not the manual one). This is the default
|
||||
* when the native implementation is available and stat/mkdir are not
|
||||
* overridden.
|
||||
*/
|
||||
function nativeSync(dir: string, opts?: Mode | Options): string|undefined;
|
||||
}
|
||||
export = mkdirp;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import mkdirp = require('mkdirp');
|
||||
|
||||
mkdirp('str', (err, made) => {
|
||||
const str: string = made;
|
||||
mkdirp('str').then(made => {
|
||||
const str: string = made;
|
||||
});
|
||||
mkdirp('str', '0777', (err, made) => {});
|
||||
mkdirp('str', {}, (err, made) => {});
|
||||
mkdirp('str', { mode: '0777' }, (err, made) => {});
|
||||
mkdirp('str', '0777').then(made => {});
|
||||
mkdirp('str', {}).then(made => {});
|
||||
mkdirp('str', { mode: '0777' }).then(made => {});
|
||||
|
||||
// $ExpectType string
|
||||
mkdirp.sync('str');
|
||||
@ -13,5 +13,7 @@ mkdirp.sync('str', '0777');
|
||||
mkdirp.sync('str', {});
|
||||
mkdirp.sync('str', { mode: '0777' });
|
||||
|
||||
// $ExpectError
|
||||
mkdirp.sync('str', { mode: '0777', fs: {} });
|
||||
mkdirp.native('str').then(m => {});
|
||||
mkdirp.manual('str').then(m => {});
|
||||
mkdirp.manualSync('str').indexOf('a');
|
||||
mkdirp.nativeSync('str').indexOf('a');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user