File size: 1,311 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# node-quick-temp
Create and remove temporary directories. Useful for build tools, like Broccoli
plugins. Smart about naming, and placing them in `./tmp` if possible, so you
don't have to worry about this.
## Installation
```bash
npm install --save quick-temp
```
## Usage
```js
var quickTemp = require('quick-temp');
```
### Creating a temporary directory
To make a temporary and assign its path to `this.tmpDestDir`, call either one
of these:
```js
quickTemp.makeOrRemake(this, 'tmpDestDir');
// or
quickTemp.makeOrReuse(this, 'tmpDestDir');
```
If `this.tmpDestDir` already contains a path, `makeOrRemake` will remove it
first and then create a new directory, whereas `makeOrReuse` will be a no-op.
Both functions also return the path of the temporary directory.
An optional third argument lets you override the class-name component of the
temporary directory name:
```js
quickTemp.makeOrRemake(this, 'tmpDestDir', 'TreeMerger');
quickTemp.makeOrRemake(this, 'tmpDestDir', this.constructor.name); // default
```
### Removing a temporary directory
To remove a previously-created temporary directory and all its contents, call
```js
quickTemp.remove(this, 'tmpDestDir');
```
This will also assign `this.tmpDestDir = null`. If `this.tmpDestDir` is
already null or undefined, it will be a no-op.
|