From 412a2d3c9d6d9b6de1d3f9eec0739e746c15a12d Mon Sep 17 00:00:00 2001 From: chencheng Date: Mon, 11 Aug 2014 11:42:25 +0800 Subject: [PATCH] fix isroot testcase --- lib/sdk/file.js | 4 ++-- tests/file.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/sdk/file.js b/lib/sdk/file.js index 01b8a73e..5ea0a34b 100644 --- a/lib/sdk/file.js +++ b/lib/sdk/file.js @@ -6,8 +6,8 @@ var log = require('../utils/log'); var file = module.exports = {}; -file.isroot = function(str) { - if (process.platform === 'win32') { +file.isroot = function(str, platform) { + if ((platform || process.platform) === 'win32') { return path.normalize(str).slice(1, 3) === ':\\'; } else { return str.charAt(0) === '/'; diff --git a/tests/file.js b/tests/file.js index b16181d0..828484ec 100644 --- a/tests/file.js +++ b/tests/file.js @@ -5,9 +5,8 @@ describe('file', function() { it('isroot', function() { file.isroot('/').should.eql(true); var oldPlatform = process.platform; - process.platform = 'win32'; - file.isroot('C:\\').should.eql(true); - file.isroot('D:\\').should.eql(true); + file.isroot('C:\\', 'win32').should.eql(true); + file.isroot('D:\\', 'win32').should.eql(true); process.platform = oldPlatform; });