Last active
April 13, 2017 18:28
-
-
Save miguelmota/a3b1153c3afc9dfb73a4762264f8d4d3 to your computer and use it in GitHub Desktop.
Node.js check if exact filename exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = __dirname; | |
var filename = 'test.txt'; | |
var files = fs.readdirSync(path); | |
var exists = files.includes(filename); | |
// true if file on disk is "test.txt", | |
// false if file on disk is "TEST.txt" | |
// fs.existsSync() will return true hence not using | |
console.log(exists); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment