Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

temporary

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temporary - npm Package Compare versions

Comparing version 0.0.8 to 1.0.0

4

History.md

@@ -0,2 +1,6 @@

1.0.0 / 2019-01-24
==================
* Updated to modern node.
0.0.8 / 2014-01-05

@@ -3,0 +7,0 @@ ==================

4

index.js
/**
* Temporary - The lord of tmp.
*
*
* Author: Veselin Todorov <hi@vesln.com>

@@ -11,3 +11,3 @@ * Licensed under the MIT License.

*/
var package = require('package')(module);
var package = require('./package.json');

@@ -14,0 +14,0 @@ /**

@@ -23,3 +23,3 @@ /**

this.init(name);
};
}

@@ -30,5 +30,20 @@ /**

* @param {String|null} name
* @param {Object} [options] Overrides
* @param {Boolean} [options.generator] - Custom filename generator
*/
Base.prototype.init = function(name) {
var filename = generator.build(name);
Base.prototype.init = function(name, options) {
options = options || {};
var filename;
if (options.generator) {
filename = options.generator(name);
} else if (options.generator === false) {
filename = name;
} else {
filename = generator.build(name);
}
this.create(filename);

@@ -44,4 +59,7 @@ this.path = filename;

*/
Base.prototype.prepareArgs = function(args) {
Base.prototype.prepareArgs = function(args, defaults) {
args = Array.prototype.slice.call(args);
if (defaults) {
args = args.concat(defaults.splice(args.length));
}
args.unshift(this.path);

@@ -48,0 +66,0 @@ return args;

@@ -21,6 +21,7 @@ /**

* @param {String|null} name
* @param {Object} [options] Overrides for directory naming
*/
function Dir(name) {
this.init(name);
};
function Dir(name, options) {
this.init(name, options);
}

@@ -45,3 +46,3 @@ /**

Dir.prototype.rmdir = function() {
fs.rmdir.apply(fs, this.prepareArgs(arguments));
fs.rmdir.apply(fs, this.prepareArgs(arguments, [function(err) {throw Error(err)}]));
};

@@ -48,0 +49,0 @@

@@ -44,3 +44,3 @@ /**

File.prototype.readFile = function() {
fs.readFile.apply(fs, this.prepareArgs(arguments));
fs.readFile.apply(fs, this.prepareArgs(arguments, [function(err) {throw Error(err)}]));
};

@@ -59,3 +59,3 @@

File.prototype.writeFile = function() {
fs.writeFile.apply(fs, this.prepareArgs(arguments));
fs.writeFile.apply(fs, this.prepareArgs(arguments, ['', {}, function(err) {throw Error(err)}]));
};

@@ -74,3 +74,3 @@

File.prototype.open = function() {
fs.open.apply(fs, this.prepareArgs(arguments));
fs.open.apply(fs, this.prepareArgs(arguments, [function(err) {throw Error(err)}]));
};

@@ -89,3 +89,3 @@

File.prototype.close = function() {
fs.close.apply(fs, Array.prototype.slice.call(arguments));
fs.close.apply(fs, Array.prototype.slice.call(arguments, [function(err) {throw Error(err)}]));
};

@@ -104,3 +104,3 @@

File.prototype.unlink = function() {
fs.unlink.apply(fs, this.prepareArgs(arguments));
fs.unlink.apply(fs, this.prepareArgs(arguments, [function(err) {throw Error(err)}]));
};

@@ -107,0 +107,0 @@

{
"name": "temporary"
, "version": "0.0.8"
, "description": "The lord of tmp."
, "keywords": ["tmp", "temp", "tempfile", "tempdirectory"]
, "author": "Veselin Todorov <hi@vesln.com>"
, "dependencies": {
"package": ">= 1.0.0 < 1.2.0"
}
, "devDependencies": {
"mocha": "1.2.x"
, "chai": "*"
, "sinon": "1.2.0"
}
, "repository" : {
"type" : "git",
"url" : "http://github.com/vesln/temporary.git"
}
, "homepage": "http://github.com/vesln/temporary"
, "scripts": {
"test": "make test"
}
, "main": "index"
, "engines": { "node": ">= 0.6.0" }
"name": "temporary",
"version": "1.0.0",
"description": "The lord of tmp.",
"keywords": [
"tmp",
"temp",
"tempfile",
"tempdirectory"
],
"contrubutors": [
"Veselin Todorov <hi@vesln.com>",
"Will Soctt <willscott@gmail.com>"
],
"license": "MIT",
"devDependencies": {
"mocha": "5.2.0",
"chai": "*",
"sinon": "7.2.3"
},
"repository": {
"type": "git",
"url": "https://github.com/vesln/temporary.git"
},
"homepage": "https://github.com/vesln/temporary",
"scripts": {
"test": "mocha --reporter spec test/*.test.js"
},
"main": "index"
}

@@ -24,9 +24,31 @@ [![Build Status](https://secure.travis-ci.org/vesln/temporary.png)](http://travis-ci.org/vesln/temporary)

var dir = new tmp.Dir();
console.log(file.path); // path.
console.log(dir.path); // path.
file.unlink();
dir.rmdir();
### Custom path
If you want to manually specify the directory name, you can do so by setting the `generator` option to `false`.
```js
var tmp = require('temporary');
var dir = new tmp.Dir('foobar', { generator: false });
console.log(dir.path) // prints 'foobar'
```
### Custom generator
Generators allow you to specify how the directory or file names get generated.
```js
var tmp = require('temporary');
var dir = new tmp.Dir('foobar', { generator: function() {} });
```
## Methods

@@ -60,2 +82,4 @@

Current maintainer: @willscott
## License

@@ -62,0 +86,0 @@

@@ -17,4 +17,5 @@ /**

var sinon = require('sinon');
var should = require('chai').should();
require('chai').should();
describe('Tempdir', function() {

@@ -26,2 +27,24 @@ it('should create file', function() {

it('should use the directory name as the path when generator option equals false', function () {
var tmp = new Tempdir('foo', {
generator: false
});
existsSync(tmp.path).should.be.ok;
(tmp.path).should.be.equal('foo');
tmp.rmdirSync();
});
it('should use the custom generator if supplied', function() {
var spy = sinon.spy(function(name) { return name; });
var tmp = new Tempdir('foo', {
generator: spy
});
(spy.called).should.be.ok;
tmp.rmdirSync();
});
describe('rmdir', function() {

@@ -31,3 +54,3 @@ it('should remove the directory', function() {

sinon.spy(fs, 'rmdir');
tmp.rmdir();
tmp.rmdir(function() {});
fs.rmdir.getCall(0).args[0].should.eql(tmp.path);

@@ -34,0 +57,0 @@ fs.rmdir.restore();

@@ -29,3 +29,3 @@ /**

var tmp = new Tempfile;
tmp.readFile();
tmp.readFile(function() {});
fs.readFile.getCall(0).args[0].should.eql(tmp.path);

@@ -50,3 +50,3 @@ fs.readFile.restore();

var tmp = new Tempfile;
tmp.writeFile();
tmp.writeFile('test.txt', {}, function() {});
fs.writeFile.getCall(0).args[0].should.eql(tmp.path);

@@ -71,3 +71,3 @@ fs.writeFile.restore();

var tmp = new Tempfile;
tmp.open('r');
tmp.open('r', function() {});
fs.open.getCall(0).args[0].should.eql(tmp.path);

@@ -93,3 +93,3 @@ fs.open.restore();

var fd = tmp.openSync('r');
tmp.close(fd);
tmp.close(fd, function() {});
fs.close.getCall(0).args[0].should.eql(fd);

@@ -115,3 +115,3 @@ fs.close.restore();

var tmp = new Tempfile;
tmp.unlink();
tmp.unlink(function() {});
fs.unlink.getCall(0).args[0].should.eql(tmp.path);

@@ -118,0 +118,0 @@ fs.unlink.restore();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc