Blame view

node_modules/cosmiconfig/dist/loadPackageProp.js 850 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
24
25
26
27
28
29
30
31
32
  //      
  'use strict';
  
  const path = require('path');
  const readFile = require('./readFile');
  const parseJson = require('./parseJson');
  
  module.exports = function loadPackageProp(
    packageDir        ,
    options   
                          
                     
     
  )                                                     {
    const packagePath = path.join(packageDir, 'package.json');
  
    function parseContent(content         )                      {
      if (!content) return null;
      const parsedContent = parseJson(content, packagePath);
      const packagePropValue = parsedContent[options.packageProp];
      if (!packagePropValue) return null;
  
      return {
        config: packagePropValue,
        filepath: packagePath,
      };
    }
  
    return !options.sync
      ? readFile(packagePath).then(parseContent)
      : parseContent(readFile.sync(packagePath));
  };