Currently, dirty throws an error when called with a file that does not exist. It still creates the file, though, so that subsequent attempts are successful.
Example:
var Dirty = require( "dirty" )
, path = require( "path" )
, real = "real.db"
, imaginary = "imaginary.db"
require( "fs" ).writeFileSync( real, "" )
process.on( "uncaughtException", function( err ) {
console.log( "Caught exception: " + err )
});
path.exists( real, function( exists ) {
console.log( real + " exists? " + exists )
})
path.exists( imaginary, function( exists ) {
console.log( imaginary + " exists? " + exists )
})
Dirty( "real.db" )
Dirty( "imaginary.db" )
path.exists( real, function( exists ) {
console.log( real + " exists? " + exists )
})
path.exists( imaginary, function( exists ) {
console.log( imaginary + " exists? " + exists )
})
which outputs:
$ node dirty.js
real.db exists? true
imaginary.db exists? false
Caught exception: Error: ENOENT, No such file or directory 'imaginary.db'
real.db exists? true
imaginary.db exists? true
Currently,
dirtythrows an error when called with a file that does not exist. It still creates the file, though, so that subsequent attempts are successful.Example:
which outputs: