Blame view

node_modules/loopback-boot/lib/utils.js 681 Bytes
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  // Copyright IBM Corp. 2014,2016. All Rights Reserved.
  // Node module: loopback-boot
  // This file is licensed under the MIT License.
  // License text available at https://opensource.org/licenses/MIT
  
  var fs = require('fs');
  
  exports.fileExistsSync = fileExistsSync;
  
  /**
   * Check synchronously if a filepath points to an existing file.
   * Replaces calls to fs.existsSync, which is deprecated (see:
   * https://github.com/nodejs/node/pull/166).
   *
   * @param   {String} filepath The absolute path to check
   * @returns {Boolean}  True if the file exists
   */
  function fileExistsSync(filepath) {
    try {
      fs.statSync(filepath);
      return true;
    } catch (e) {
      return false;
    }
  }