File tree Expand file tree Collapse file tree 4 files changed +22
-29
lines changed Expand file tree Collapse file tree 4 files changed +22
-29
lines changed Original file line number Diff line number Diff line change 11import fs from 'fs'
22import isNode from '../isNode'
3+ import getFileStats from './getFileStats'
34
45const collectDirectorySize = fileList => {
56 let size = 0
@@ -20,16 +21,6 @@ const collectDirectorySize = fileList => {
2021 return size
2122}
2223
23- const getFileStats = file => {
24- let stats
25- if ( ! file . stats ) {
26- try {
27- stats = fs . statSync ( file . path )
28- } catch ( err ) {
29- stats = { size : 0 }
30- }
31- }
32- return stats
33- }
24+ module . exports = collectDirectorySize
3425
3526export default collectDirectorySize
Original file line number Diff line number Diff line change 1+ import fs from 'fs'
2+
3+ function getFileStats ( file ) {
4+ let stats
5+ if ( ! file . stats ) {
6+ try {
7+ stats = fs . statSync ( file . path )
8+ } catch ( err ) {
9+ stats = { size : 0 }
10+ }
11+ }
12+ return stats
13+ }
14+
15+ export default getFileStats
Original file line number Diff line number Diff line change 11// dependencies -------------------------------------------------------------------
2-
32import FileAPI from './FileAPI'
43
54import newFile from './newFile'
@@ -13,24 +12,10 @@ import collectDirectorySize from './collectDirectorySize'
1312import illegalCharacterTest from './illegalCharacterTest'
1413import sessions from './sessions'
1514import remoteFiles from './remoteFiles'
15+ import getFileStats from './getFileStats'
1616
1717// public API ---------------------------------------------------------------------
1818
19- export {
20- FileAPI ,
21- newFile ,
22- readFile ,
23- readDir ,
24- readNiftiHeader ,
25- generateMergedSidecarDict ,
26- potentialLocations ,
27- getBFileContent ,
28- collectDirectorySize ,
29- illegalCharacterTest ,
30- sessions ,
31- remoteFiles ,
32- }
33-
3419export default {
3520 FileAPI,
3621 newFile,
@@ -44,4 +29,5 @@ export default {
4429 illegalCharacterTest,
4530 sessions,
4631 remoteFiles,
32+ getFileStats,
4733}
Original file line number Diff line number Diff line change @@ -39,9 +39,10 @@ export default {
3939 */
4040 loadConfig : function ( config , callback ) {
4141 if ( typeof config === 'string' ) {
42- // load file
42+ var configFile = { path : config }
43+ configFile . stats = files . getFileStats ( configFile )
4344 files
44- . readFile ( { path : config } )
45+ . readFile ( configFile )
4546 . then ( contents => {
4647 callback ( null , { path : config } , contents )
4748 } )
You can’t perform that action at this time.
0 commit comments