Skip to content

Commit

Permalink
Bug fix to address using absolute paths on Windows and child resolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
nullivex committed Sep 16, 2015
1 parent e4d209a commit 6d9fc0b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ $ DEBUG=infant* node app

## Changelog

### 0.9.5
* Bug fix to address using absolute paths on Windows and child resolution.
* Added test against windows absolute paths
* Bump dependencies

### 0.9.4
* Improved debug logging on recycling
* Now deletes worker connection counters after recycling (prevent mem leaks)
Expand Down
2 changes: 1 addition & 1 deletion helpers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var path = require('path')
exports.resolveFile = function(file,level){
//resolve file
if(!file) file = process.argv[1]
else if(!file.match(/^\//)){
else if(!file.match(/^\//) && !file.match(/^[A-Z]:/)){
//resolve the dir of the caller
file = path.resolve(
[path.dirname(callsite()[level || 2].getFileName()),file].join('/')
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "SnailJS <developers@snailjs.org>",
"name": "infant",
"description": "Child process, and cluster helper for Node.js",
"version": "0.9.4",
"version": "0.9.5",
"homepage": "http://snailjs.org/",
"repository": {
"type": "git",
Expand All @@ -21,19 +21,19 @@
"node": ">=0.10.0"
},
"dependencies": {
"async": "0.9.x",
"async": "1.4.x",
"callsite": "1.0.x",
"debug": "2.0.x",
"debug": "2.2.x",
"node-sigint": "0.0.x",
"object-manage": "0.8.x",
"q": "1.0.x"
"q": "1.4.x"
},
"scripts": {
"test": "node ./node_modules/mocha/bin/mocha"
},
"devDependencies": {
"chai": "1.9.x",
"mocha": "1.21.x",
"request": "2.44.x"
"chai": "3.2.x",
"mocha": "2.3.x",
"request": "2.62.x"
}
}
28 changes: 28 additions & 0 deletions test/util.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
var expect = require('chai').expect

var infantUtil = require('../helpers/util')


describe('helpers/util',function(){
describe('resolveFile',function(){
it('should resolve relative paths',function(done){
var file = infantUtil.resolveFile('./config')
expect(file).to.be.a('string')
expect(file).to.not.equal('./config')
done()
})
it('should not resolve absolute UNIX paths',function(done){
var file = infantUtil.resolveFile('/var/config')
expect(file).to.be.a('string')
expect(file).to.equal('/var/config')
done()
})
it('should not resolve absolute Windows paths',function(done){
var file = infantUtil.resolveFile('C:/foo')
expect(file).to.be.a('string')
expect(file).to.equal('C:/foo')
done()
})
})
})

0 comments on commit 6d9fc0b

Please sign in to comment.