MCPcopy Create free account
hub / github.com/FSGModding/FSG_Mod_Assistant / countFiles

Function countFiles

test/tests/packagestat.js:81–104  ·  view source on GitHub ↗
(test)

Source from the content-addressed store, hash-verified

79const tblHeader = '| ----------- | ----: | ----: | -----: | -----: | ---------: | -------: |'
80
81const countFiles = (test) => {
82 return glob('**', { cwd : path.join(__dirname, '..', '..'), ignore : 'node_modules/**', stat : true, withFileTypes : true }).then((results) => {
83 test.step(`Current App Version is ${pkgDetail.version}`)
84 test.step('Current File Statistics:\n')
85 const fileList = results.filter((x) => x.isFile())
86 test.step_fmt(makeLine('', { blank : 'Blank', code : 'Code', comment : '/* */', size : 'Size', total : 'Files' }))
87 test.step_fmt(tblHeader)
88 test.step_fmt(makeLine('javaScript', countTextFile(fileList.filter((x) => path.extname(x.name) === '.js' && path.basename(x.name) !== 'baseGameData.js' && path.basename(x.name) !== 'baseGameData19.js'), true)))
89 test.step_fmt(makeLine('JSON', countTextFile(fileList.filter((x) => path.extname(x.name) === '.json'))))
90 test.step_fmt(makeLine('XML', countTextFile(fileList.filter((x) => path.extname(x.name) === '.xml'))))
91 test.step_fmt(makeLine('HTML', countTextFile(fileList.filter((x) => path.extname(x.name) === '.html'))))
92 test.step_fmt(makeLine('CSS', countTextFile(fileList.filter((x) => path.extname(x.name) === '.css' || path.extname(x.name) === '.scss'), true)))
93 test.step_fmt(makeLine('markDown', countTextFile(fileList.filter((x) => path.extname(x.name) === '.md'))))
94 test.step_fmt(makeLine('Images', countOthers(fileList.filter((x) => imgSet.has(path.extname(x.name)) ))))
95 test.step_fmt(makeLine('ZIP Archive', countOthers(fileList.filter((x) => path.extname(x.name) === '.zip'))))
96 test.step_fmt(makeLine('Other', countOthers(fileList.filter((x) => !knowSet.has(path.extname(x.name)) ))))
97 // test.step_fmt(tblHeader)
98 test.step_fmt(makeLine('TOTAL', countOthers(fileList)))
99 }).catch((err) => {
100 test.error(err)
101 }).finally(() => {
102 test.end()
103 })
104}

Callers 1

packagestat.jsFile · 0.85

Calls 8

makeLineFunction · 0.85
countTextFileFunction · 0.85
countOthersFunction · 0.85
stepMethod · 0.80
step_fmtMethod · 0.80
hasMethod · 0.80
endMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected