UNPKG

617 BJavaScriptView Raw
1var $, fs;
2
3$ = {};
4
5$.normalizePath = require('../dist/normalizePath');
6
7$.isExisted_ = require('../dist/isExisted_');
8
9$.info = require('../dist/info');
10
11$.wrapList = require('../dist/wrapList');
12
13fs = require('fs');
14
15module.exports = async function(source) {
16 source = $.normalizePath(source);
17 if (!(await $.isExisted_(source))) {
18 $.info('file', `${$.wrapList(source)} not existed`);
19 return null;
20 }
21 // return
22 return new Promise(function(resolve) {
23 return fs.stat(source, function(err, stat) {
24 if (err) {
25 throw new Error(err);
26 }
27 return resolve(stat);
28 });
29 });
30};