Blame view

node_modules/cosmiconfig/dist/getDirectory.js 568 Bytes
2a09d1a4   liuqimichale   添加宜春 天水 宣化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  //      
  'use strict';
  
  const path = require('path');
  const isDirectory = require('is-directory');
  
  module.exports = function getDirectory(
    filepath        ,
    sync          
  )                           {
    if (sync === true) {
      return isDirectory.sync(filepath) ? filepath : path.dirname(filepath);
    }
  
    return new Promise((resolve, reject) => {
      return isDirectory(filepath, (err, filepathIsDirectory) => {
        if (err) {
          return reject(err);
        }
        return resolve(filepathIsDirectory ? filepath : path.dirname(filepath));
      });
    });
  };