Find absolute base path of the project directory

后端 未结 7 1475
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 21:35

Until now we could get the absolute path of a file to open later as readStream with this code snippet:

var base = path.resolve(\'.\');
var file = base + \'/d         


        
7条回答
  •  一生所求
    2020-12-04 22:08

    As of Meteor 1.2.1, this works for me:

    var absoluteBasePath = path.resolve('../../../../../.');
    

    The same result using split:

    var absoluteBasePath = path.resolve('.').split(path.sep + '.meteor')[0];
    

    Using process.cwd():

    var absoluteBasePath = path.resolve(process.cwd(), '../../../../../');
    var absoluteBasePath = path.resolve(process.cwd()).split(path.sep + '.meteor')[0];
    

提交回复
热议问题