Permalink
Browse files

Support 0.6 and 0.8

  • Loading branch information...
1 parent 9ab329a commit 3a03ecf0f1b1e9accb0ca038c44bfa24ecdea1ee @vesln committed Jun 25, 2012
Showing with 35 additions and 26 deletions.
  1. +2 −1 .travis.yml
  2. +8 −8 lib/base.js
  3. +4 −4 lib/dir.js
  4. +4 −4 lib/file.js
  5. +3 −1 lib/generator.js
  6. +1 −1 package.json
  7. +6 −4 test/base.test.js
  8. +4 −2 test/dir.test.js
  9. +3 −1 test/file.test.js
View
@@ -1,3 +1,4 @@
language: node_js
node_js:
- - 0.6
+ - 0.6
+ - 0.8
View
@@ -1,6 +1,6 @@
/**
* Temporary - The lord of tmp.
- *
+ *
* Author: Veselin Todorov <hi@vesln.com>
* Licensed under the MIT License.
*/
@@ -15,7 +15,7 @@ var detector = require('./detector');
/**
* Base constructor.
- *
+ *
* @param {String|null} name
*/
function Base(name) {
@@ -24,7 +24,7 @@ function Base(name) {
/**
* Initializes the class.
- *
+ *
* @param {String|null} name
*/
Base.prototype.init = function(name) {
@@ -36,7 +36,7 @@ Base.prototype.init = function(name) {
/**
* Converts the arguments object to array and
* append `this.path` as first element.
- *
+ *
* @returns {Array}
*/
Base.prototype.prepareArgs = function(args) {
@@ -47,15 +47,15 @@ Base.prototype.prepareArgs = function(args) {
/**
* Renames the dir/file.
- *
+ *
* @param {String} name
* @param {Function} cb Callback.
*/
Base.prototype.rename = function(name, cb) {
var self = this;
var args = arguments;
var tmp = path.normalize(path.dirname(self.path) + '/' + name);
-
+
fs.rename(this.path, tmp, function(err) {
self.path = tmp;
if (args.length === 2) cb(err);
@@ -64,7 +64,7 @@ Base.prototype.rename = function(name, cb) {
/**
* Renames the dir/file sync.
- *
+ *
* @param {String} name
*/
Base.prototype.renameSync = function(name) {
@@ -77,4 +77,4 @@ Base.prototype.renameSync = function(name) {
/**
* Exporting the lib.
*/
-module.exports = Base;
+module.exports = Base;
View
@@ -1,6 +1,6 @@
/**
* Temporary - The lord of tmp.
- *
+ *
* Author: Veselin Todorov <hi@vesln.com>
* Licensed under the MIT License.
*/
@@ -16,7 +16,7 @@ var Base = require('./base');
/**
* Dir constructor.
- *
+ *
* @param {String|null} name
*/
function Dir(name) {
@@ -30,7 +30,7 @@ Dir.prototype.__proto__ = Base.prototype;
/**
* Creates new file.
- *
+ *
* @param {String} dirname
*/
Dir.prototype.create = function(dirname) {
@@ -54,4 +54,4 @@ Dir.prototype.rmdirSync = function() {
/**
* Exporting the lib.
*/
-module.exports = Dir;
+module.exports = Dir;
View
@@ -1,6 +1,6 @@
/**
* Temporary - The lord of tmp.
- *
+ *
* Author: Veselin Todorov <hi@vesln.com>
* Licensed under the MIT License.
*/
@@ -16,7 +16,7 @@ var Base = require('./base');
/**
* File constructor.
- *
+ *
* @param {String|null} name
*/
function File(name) {
@@ -30,7 +30,7 @@ File.prototype.__proto__ = Base.prototype;
/**
* Creates new file.
- *
+ *
* @param {String} filename
*/
File.prototype.create = function(filename) {
@@ -110,4 +110,4 @@ File.prototype.unlinkSync = function() {
/**
* Exporting the lib.
*/
-module.exports = File;
+module.exports = File;
View
@@ -9,7 +9,9 @@
* Dependencies.
*/
var fs = require('fs');
+var path = require('path');
var detector = require('./detector');
+var existsSync = fs.existsSync || path.existsSync;
/**
* Generator namespace.
@@ -28,7 +30,7 @@ generator.name = function() {
var tmp = detector.tmp();
do {
id = Date.now() + Math.random();
- } while(fs.existsSync(tmp + '/' + id));
+ } while(existsSync(tmp + '/' + id));
return id + '';
};
View
@@ -21,5 +21,5 @@
"test": "make test"
}
, "main": "index"
- , "engines": { "node": ">= 0.7.0 < 0.9.0" }
+ , "engines": { "node": ">= 0.6.0" }
}
View
@@ -10,6 +10,8 @@
*/
var path = require('path');
var fs = require('fs');
+var existsSync = fs.existsSync || path.existsSync;
+
var Base = require('../lib/base');
var generator = require('../lib/generator');
var should = require('chai').should();
@@ -22,9 +24,9 @@ describe('Base', function() {
var tmp = new Base;
tmp.path = generator.build();
fs.mkdirSync(path.normalize(tmp.path), 0777);
- fs.existsSync(tmp.path).should.be.ok;
+ existsSync(tmp.path).should.be.ok;
tmp.rename('foo', function(err) {
- fs.existsSync(tmp.path).should.be.ok;
+ existsSync(tmp.path).should.be.ok;
done();
});
});
@@ -36,9 +38,9 @@ describe('Base', function() {
tmp.path = generator.build();
fs.mkdirSync(path.normalize(tmp.path), 0777);
var oldPath = tmp.path;
- fs.existsSync(tmp.path).should.be.ok;
+ existsSync(tmp.path).should.be.ok;
tmp.renameSync('foo3');
- fs.existsSync(tmp.path).should.be.ok;
+ existsSync(tmp.path).should.be.ok;
path.should.not.eql(oldPath);
});
});
View
@@ -8,16 +8,18 @@
/**
* Dependencies.
*/
-var path = require('path');
var fs = require('fs');
+var path = require('path');
+var existsSync = fs.existsSync || path.existsSync;
+
var Tempdir = require('../lib/dir');
var sinon = require('sinon');
var should = require('chai').should();
describe('Tempdir', function() {
it('should create file', function() {
var tmp = new Tempdir('foo');
- fs.existsSync(tmp.path).should.be.ok;
+ existsSync(tmp.path).should.be.ok;
});
describe('rmdir', function() {
View
@@ -10,14 +10,16 @@
*/
var path = require('path');
var fs = require('fs');
+var existsSync = fs.existsSync || path.existsSync;
+
var Tempfile = require('../lib/file');
var sinon = require('sinon');
var should = require('chai').should();
describe('Tempfile', function() {
it('should create file', function() {
var tmp = new Tempfile('foo');
- fs.existsSync(tmp.path).should.be.ok;
+ existsSync(tmp.path).should.be.ok;
});
describe('readFile', function() {

0 comments on commit 3a03ecf

Please sign in to comment.