Comparing version 0.0.9 to 0.0.10
{ | ||
"name": "tmp", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Temporary file and directory creator", | ||
@@ -33,3 +33,3 @@ "author": "KARASZI István <github@spam.raszi.hu> (http://raszi.hu/)", | ||
"engines": { | ||
"node": "0.4.10" | ||
"node": ">=0.4.10" | ||
}, | ||
@@ -36,0 +36,0 @@ |
@@ -24,21 +24,31 @@ # Tmp | ||
var tmp = require('tmp'); | ||
Simple temporary file creation, the file will be unlinked on process exit. | ||
tmp.file(function _tempFileCreated(err, path, fd) { | ||
if (err) throw err; | ||
```javascript | ||
var tmp = require('tmp'); | ||
console.log("File: ", path); | ||
console.log("Filedescriptor: ", fd); | ||
}); | ||
tmp.file(function _tempFileCreated(err, path, fd) { | ||
if (err) throw err; | ||
console.log("File: ", path); | ||
console.log("Filedescriptor: ", fd); | ||
}); | ||
``` | ||
### Directory creation | ||
var tmp = require('tmp'); | ||
Simple temporary directory creation, it will be removed on process exit. | ||
tmp.dir(function _tempDirCreated(err, path) { | ||
if (err) throw err; | ||
If the directory still contains items on process exit, then it won't be removed. | ||
console.log("Dir: ", path); | ||
}); | ||
```javascript | ||
var tmp = require('tmp'); | ||
tmp.dir(function _tempDirCreated(err, path) { | ||
if (err) throw err; | ||
console.log("Dir: ", path); | ||
}); | ||
``` | ||
## Advanced usage | ||
@@ -48,28 +58,44 @@ | ||
var tmp = require('tmp'); | ||
Creates a file with mode `0644`, prefix will be `prefix-` and postfix will be `.txt`. | ||
tmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileCreated(err, path, fd) { | ||
if (err) throw err; | ||
```javascript | ||
var tmp = require('tmp'); | ||
console.log("File: ", path); | ||
console.log("Filedescriptor: ", fd); | ||
}); | ||
tmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileCreated(err, path, fd) { | ||
if (err) throw err; | ||
console.log("File: ", path); | ||
console.log("Filedescriptor: ", fd); | ||
}); | ||
``` | ||
### Directory creation | ||
tmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path) { | ||
if (err) throw err; | ||
Creates a directory with mode `0755`, prefix will be `myTmpDir_`. | ||
console.log("Dir: ", path); | ||
}); | ||
```javascript | ||
var tmp = require('tmp'); | ||
tmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path) { | ||
if (err) throw err; | ||
console.log("Dir: ", path); | ||
}); | ||
``` | ||
### mkstemps like | ||
tmp.dir({ template: '/tmp/tmp-XXXXXX' }, function _tempDirCreated(err, path) { | ||
iff (err) throw err; | ||
Creates a new temporary directory with mode `0700` and filename like `/tmp/tmp-nk2J1u`. | ||
console.log("Dir: ", path); | ||
}); | ||
```javascript | ||
var tmp = require('tmp'); | ||
tmp.dir({ template: '/tmp/tmp-XXXXXX' }, function _tempDirCreated(err, path) { | ||
if (err) throw err; | ||
console.log("Dir: ", path); | ||
}); | ||
``` | ||
## Options | ||
@@ -80,3 +106,3 @@ | ||
* `mode`: the file mode to create with it fallbacks to `0600` on file creation and `0700` on directory creation | ||
* `prefix`: the optional prefix, fallback to `tmp-` if not provided | ||
* `prefix`: the optional prefix, fallbacks to `tmp-` if not provided | ||
* `postfix`: the optional postfix, fallbacks to `.tmp` on file creation | ||
@@ -83,0 +109,0 @@ * `template`: [`mkstemps`][3] like filename template, no default |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16682
114