@@ -7,11 +7,17 @@ import UnsupportedFilesystemItemError from '../errors/UnsupportedFilesystemItemE
77 * Class to flatten file structure with markdown data
88 */
99export default class FileStructureFlatterer {
10+
11+ /**
12+ * @type {import('fs') }
13+ */
14+ #fs
15+
1016 /**
11- * @param {object } fs - Filesystem module
17+ * @param {import('fs') } fs - Filesystem module
1218 */
1319 constructor ( fs ) {
14- this . _fs = fs
20+ this . #fs = fs
1521 }
1622
1723 /**
@@ -46,12 +52,12 @@ export default class FileStructureFlatterer {
4652 const dirs = [ '.' ]
4753 while ( dirs . length > 0 ) {
4854 const dir = dirs . pop ( )
49- const contents = this . _fs . readdirSync ( `${ path } /${ dir } ` )
55+ const contents = this . #fs . readdirSync ( `${ path } /${ dir } ` )
5056
5157 for ( const item of contents ) {
5258 const relativePath = `${ dir } /${ item . toString ( ) } `
5359 const fullPath = `${ path } /${ relativePath } `
54- const info = this . _fs . lstatSync ( fullPath )
60+ const info = this . #fs . lstatSync ( fullPath )
5561 if ( info . isDirectory ( ) ) {
5662 dirs . push ( relativePath )
5763 continue
@@ -111,7 +117,7 @@ export default class FileStructureFlatterer {
111117 if ( isDebug ( ) ) {
112118 debug ( ` Fixing ${ filename } ...` )
113119 }
114- const content = this . _fs . readFileSync ( filename , 'utf8' )
120+ const content = this . #fs . readFileSync ( filename , 'utf8' )
115121 const allPossibleFilenames = { }
116122 for ( const oldFilename in filenames ) {
117123 const currentFilename = filenames [ oldFilename ]
@@ -154,7 +160,7 @@ export default class FileStructureFlatterer {
154160 if ( isDebug ( ) ) {
155161 debug ( ' Changed.' )
156162 }
157- this . _fs . writeFileSync ( filename , newContent )
163+ this . #fs . writeFileSync ( filename , newContent )
158164 }
159165 }
160166
@@ -200,7 +206,7 @@ export default class FileStructureFlatterer {
200206 if ( isDebug ( ) ) {
201207 debug ( ` Renaming ${ oldFilename } -> ${ newFilename } ...` )
202208 }
203- this . _fs . renameSync (
209+ this . #fs . renameSync (
204210 newDocs . concat ( '/' , oldFilename ) ,
205211 newDocs . concat ( '/' , newFilename )
206212 )
0 commit comments