-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathprojectInfo.js
More file actions
26 lines (24 loc) · 817 Bytes
/
Copy pathprojectInfo.js
File metadata and controls
26 lines (24 loc) · 817 Bytes
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
var ignore = require("surge-ignore")
var fsReader = require('fstream-ignore')
var fs = require("fs")
module.exports = function (path) {
return new Promise(function (resolve, reject) {
var projectSize = 0;
var fileCount = 0
var project = fsReader({ 'path': path, ignoreFiles: [".surgeignore"] })
project.addIgnoreRules(ignore)
project.on("child", function (c) {
fs.lstat(c.path, function(err, stats) {
projectSize += stats.size
if (!stats.isDirectory()) fileCount++
})
}).on("close", function() {
resolve({
projectSize: projectSize,
fileCount: fileCount
})
}).on("error", function (err) {
reject(err)
})
})
}