Get rid of deprecated `fs.existSync`

Reviewed By: mmahoney

Differential Revision: D2824569

fb-gh-sync-id: efed6e88f566110b8286ea59563c2904b3dd8059
This commit is contained in:
Martín Bigio 2016-01-12 16:44:18 -08:00 committed by facebook-github-bot-8
parent 91fb94b5ce
commit 1b33b523f4
1 changed files with 10 additions and 1 deletions

View File

@ -49,7 +49,7 @@ const SocketInterface = {
sockPath = '\\\\.\\pipe\\' + sockPath sockPath = '\\\\.\\pipe\\' + sockPath
} }
if (fs.existsSync(sockPath)) { if (existsSync(sockPath)) {
var sock = net.connect(sockPath); var sock = net.connect(sockPath);
sock.on('connect', () => { sock.on('connect', () => {
SocketClient.create(sockPath).then( SocketClient.create(sockPath).then(
@ -135,4 +135,13 @@ function createServer(resolve, reject, options, sockPath) {
}); });
} }
function existsSync(filename) {
try {
fs.accessSync(filename);
return true;
} catch(ex) {
return false;
}
}
module.exports = SocketInterface; module.exports = SocketInterface;