Compare commits

..

6 Commits

Author SHA1 Message Date
5493d3cd5d 4.2.10 2017-05-07 20:51:02 +02:00
bd50c122eb fix isDirectory() to return false instead of failing 2017-05-07 20:50:59 +02:00
51f9d76a64 4.2.9 2017-05-02 00:07:43 +02:00
c2f809f9cf revert false assumption 2017-05-02 00:07:39 +02:00
9f311984ac 4.2.8 2017-05-01 23:38:59 +02:00
7515ecf9ce toStringSynv now creates normal strings 2017-05-01 23:38:56 +02:00
4 changed files with 17 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "smartfile",
"version": "4.2.7",
"version": "4.2.10",
"description": "offers smart ways to work with files in nodejs",
"main": "dist/index.js",
"typings": "dist/index.d.ts",

View File

@ -53,8 +53,8 @@ tap.test('.fs.listFileTree() -> should get a file tree', async () => {
tap.test('.fs.fileTreeToObject -> should read a file tree into an Object', async () => {
let fileArrayArg = await smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.txt')
expect(fileArrayArg[0].contents.toString()).to.not.be.null
// expect(fileArrayArg[1]).to.be.instanceof(smartfile.Smartfile)
expect(fileArrayArg[0]).to.be.instanceof(smartfile.Smartfile)
expect(fileArrayArg[0].contents.toString()).to.equal(fileArrayArg[0].contentBuffer.toString())
})
tap.test('.fs.copy() -> should copy a directory', async () => {

View File

@ -43,7 +43,11 @@ export let fileExists = function (filePath) {
* Checks if given path points to an existing directory
*/
export let isDirectory = function (pathArg): boolean {
return plugins.fsExtra.statSync(pathArg).isDirectory()
try {
return plugins.fsExtra.statSync(pathArg).isDirectory()
} catch (err) {
return false
}
}
/**
@ -203,8 +207,8 @@ export let toObjectSync = function (filePathArg, fileTypeArg?) {
* @param filePath
* @returns {string|Buffer|any}
*/
export let toStringSync = function (filePath: string) {
let fileString = plugins.fsExtra.readFileSync(filePath, 'utf8')
export let toStringSync = function (filePath: string): string {
let fileString: any = plugins.fsExtra.readFileSync(filePath, 'utf8')
return fileString
}