Skip to content
Snippets Groups Projects
Commit 9e965aab authored by Sigmund, Dominik's avatar Sigmund, Dominik
Browse files

Better File Checks!

parent 6715f1f6
Branches
Tags
1 merge request!1Update index.test.js, examples/all-options.js, examples/log-to-file.js,...
......@@ -28,10 +28,17 @@ function Log (options) {
this.fs = require('fs')
this.path = require('path')
this.options.file = this.path.resolve(this.options.file)
if (!this.fs.lstatSync(this.options.file).isFile()) {
throw new Error(this.options.file + ' is not a File...')
}
try {
this.fs.accessSync(this.options.file, this.fs.constants.R_OK | this.fs.constants.W_OK)
} catch (err) {
try {
this.fs.writeFileSync(this.options.file, '')
} catch (err) {
throw new Error('Could not Create File ' + this.options.file + '\n' + err.toString())
}
}
}
this.info = function (message, tags) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment