Remove unused fsUtils.isFile()

This commit is contained in:
Juan Cruz Viotti 2014-11-07 14:17:05 -04:00
parent f00691529a
commit cad1d5764b
2 changed files with 0 additions and 63 deletions

View File

@ -1,27 +1,4 @@
fs = require('fs')
_ = require('lodash')
async = require('async')
exports.isValidPath = (p) ->
return _.isString(p)
exports.isFile = (file, outerCallback) ->
async.waterfall([
# Check if the file exists
(callback) ->
fs.exists file, (exists) ->
return callback(null, exists)
# Get file stats
(exists, callback) ->
if not exists
return outerCallback(null, false)
fs.stat(file, callback)
# Check if it's a file
(stats, callback) ->
return callback(null, !!stats.isFile())
], outerCallback)

View File

@ -1,17 +1,6 @@
expect = require('chai').expect
_ = require('lodash')
mockFs = require('mock-fs')
fsUtils = require('./fs-utils')
PATHS =
file:
name: '/tmp/file1'
contents: 'File1 contents'
directory:
name: '/tmp/dir'
contents: mockFs.directory()
describe 'FsUtils:', ->
describe '#isValidPath()', ->
@ -36,32 +25,3 @@ describe 'FsUtils:', ->
'./file/../file2'
]
expect(fsUtils.isValidPath(validPath)).to.be.true
describe '#isFile()', ->
beforeEach ->
mockFsOptions = {}
for key, value of PATHS
mockFsOptions[value.name] = value.contents
mockFs(mockFsOptions)
afterEach ->
mockFs.restore()
it 'should return true for files', (done) ->
fsUtils.isFile PATHS.file.name, (error, isFile) ->
expect(error).to.not.exist
expect(isFile).to.be.true
done()
it 'should return false if file doesn\'t exists', (done) ->
fsUtils.isFile '/nonexistentfile', (error, isFile) ->
expect(error).to.not.exist
expect(isFile).to.be.false
done()
it 'should return false if path is a directory', (done) ->
fsUtils.isFile PATHS.directory.name, (error, isFile) ->
expect(error).to.not.exist
expect(isFile).to.be.false
done()