felixge / felixge/node-dirty

`Error: ENOENT, No such file or directory` when db doesn't already exist.

Open
#16 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
619
Forks
64
PR merge metrics
No merged PRs in 30d

Description

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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.