diff --git a/lib/fs-utils/fs-utils.coffee b/lib/fs-utils/fs-utils.coffee index 83a12a15..b3eb37f8 100644 --- a/lib/fs-utils/fs-utils.coffee +++ b/lib/fs-utils/fs-utils.coffee @@ -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) diff --git a/lib/fs-utils/fs-utils.spec.coffee b/lib/fs-utils/fs-utils.spec.coffee index e9e96871..ff6d8ca8 100644 --- a/lib/fs-utils/fs-utils.spec.coffee +++ b/lib/fs-utils/fs-utils.spec.coffee @@ -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()