Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 18, 2020
1 parent f7fc51f commit ae9af82
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
26 changes: 13 additions & 13 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import {MergeExclusive, TypedArray} from 'type-fest';

declare namespace tempy {
type FileOptions = MergeExclusive<
{
/**
{
/**
File extension.
Mutually exclusive with the `name` option.
_You usually won't need this option. Specify it only when actually needed._
*/
readonly extension?: string;
},
{
/**
readonly extension?: string;
},
{
/**
Filename.
Mutually exclusive with the `extension` option.
_You usually won't need this option. Specify it only when actually needed._
*/
readonly name?: string;
}
readonly name?: string;
}
>;

type DirectoryOptions = {
Expand All @@ -34,7 +34,7 @@ declare namespace tempy {
Useful for testing by making it easier to identify cache directories that are created.
*/
readonly prefix?: string;
}
};
}

declare const tempy: {
Expand All @@ -58,7 +58,7 @@ declare const tempy: {
//=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
```
*/
file(options?: tempy.FileOptions): string;
file: (options?: tempy.FileOptions) => string;

/**
Get a temporary directory path. The directory is created for you.
Expand All @@ -74,7 +74,7 @@ declare const tempy: {
//=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/name_3c085674ad31223b9653c88f725d6b41'
```
*/
directory(options?: tempy.DirectoryOptions): string;
directory: (options?: tempy.DirectoryOptions) => string;

/**
Write data to a random temp file.
Expand All @@ -87,7 +87,7 @@ declare const tempy: {
//=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
```
*/
write(fileContent: string | Buffer | TypedArray | DataView | NodeJS.ReadableStream, options?: tempy.FileOptions): Promise<string>;
write: (fileContent: string | Buffer | TypedArray | DataView | NodeJS.ReadableStream, options?: tempy.FileOptions) => Promise<string>;

/**
Synchronously write data to a random temp file.
Expand All @@ -100,7 +100,7 @@ declare const tempy: {
//=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
```
*/
writeSync(fileContent: string | Buffer | TypedArray | DataView, options?: tempy.FileOptions): string;
writeSync: (fileContent: string | Buffer | TypedArray | DataView, options?: tempy.FileOptions) => string;

/**
Get the root temporary directory path.
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expectType, expectError} from 'tsd';
import tempy = require('.');

const options: tempy.FileOptions = {};
const options: tempy.FileOptions = {}; // eslint-disable-line @typescript-eslint/no-unused-vars
expectType<string>(tempy.directory());
expectType<string>(tempy.directory({prefix: 'name_'}));
expectType<string>(tempy.file());
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@
"dependencies": {
"is-stream": "^2.0.0",
"temp-dir": "^2.0.0",
"type-fest": "^0.12.0",
"type-fest": "^0.16.0",
"unique-string": "^2.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.11.0",
"xo": "^0.25.4"
"ava": "^2.4.0",
"tsd": "^0.13.1",
"xo": "^0.32.1"
},
"xo": {
"rules": {
"node/no-unsupported-features/node-builtins": "off"
}
}
}
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tempy [![Build Status](https://travis-ci.org/sindresorhus/tempy.svg?branch=master)](https://travis-ci.org/sindresorhus/tempy)
# tempy [![Build Status](https://travis-ci.com/sindresorhus/tempy.svg?branch=master)](https://travis-ci.com/github/sindresorhus/tempy)

> Get a random temporary file or directory path
Expand Down Expand Up @@ -63,14 +63,15 @@ Type: `Object`

##### prefix

_You usually won't need this option. Specify it only when actually needed._

Type: `string`

Directory prefix.

Useful for testing by making it easier to identify cache directories that are created.

*You usually won't need this option. Specify it only when actually needed.*

### tempy.write(fileContent, options?)

Write data to a random temp file.
Expand Down

0 comments on commit ae9af82

Please sign in to comment.