@@ -6,8 +6,7 @@ var path = require('path');
66var fs = require ( 'node:fs' ) ;
77var os = require ( 'os' ) ;
88var crypto = require ( 'crypto' ) ;
9- var fg = require ( 'fast-glob' ) ;
10- var fs$1 = require ( 'fs' ) ;
9+ var FileSet = require ( 'file-set' ) ;
1110var assert = require ( 'assert' ) ;
1211var walkBack = require ( 'walk-back' ) ;
1312var currentModulePaths = require ( 'current-module-paths' ) ;
@@ -40,82 +39,6 @@ class TempFile {
4039 }
4140}
4241
43- class FileSet {
44- constructor ( ) {
45- /* validation */
46- if ( arguments . length ) {
47- throw new Error ( 'new Fileset() does not require any arguments' )
48- }
49-
50- /** • fileSet.files :string[]
51- ≈ The existing files found.
52- */
53- this . files = [ ] ;
54-
55- /** • fileSet.dirs :string[]
56- ≈ The existing directories found. Directory paths will always end with `'/'`.
57- */
58- this . dirs = [ ] ;
59-
60- /** • fileSet.notExisting :string[]
61- ≈ Paths which were not found.
62- */
63- this . notExisting = [ ] ;
64- }
65-
66- /** ø fileSet.add(patterns)
67- ≈ Add file patterns to the set.
68- • [patterns] :string|string[] - One or more file paths or glob expressions to inspect.
69- */
70- async add ( files , options = { } ) {
71- files = arrayify ( files ) ;
72- for ( let file of files ) {
73- /* Force all incoming file paths and glob expressions to use posix separators */
74- file = os . platform ( ) === 'win32'
75- ? file . replace ( / \\ / g, path . posix . sep )
76- : file ;
77- try {
78- const stat = await fs$1 . promises . stat ( file ) ;
79- if ( stat . isFile ( ) && ! this . files . includes ( file ) ) {
80- this . files . push ( file ) ;
81- } else if ( stat . isDirectory ( ) && ! this . dirs . includes ( file ) ) {
82- this . dirs . push ( file . endsWith ( path . posix . sep ) ? file : `${ file } ${ path . posix . sep } ` ) ;
83- }
84- } catch ( err ) {
85- if ( err . code === 'ENOENT' ) {
86- if ( fg . isDynamicPattern ( file ) ) {
87- const found = await fg . glob ( file , { onlyFiles : false , markDirectories : true } ) ;
88- if ( found . length ) {
89- if ( options . globResultSortFn ) {
90- found . sort ( options . globResultSortFn ) ;
91- }
92- for ( const match of found ) {
93- if ( match . endsWith ( path . posix . sep ) ) {
94- if ( ! this . dirs . includes ( match ) ) this . dirs . push ( match ) ;
95- } else {
96- if ( ! this . files . includes ( match ) ) this . files . push ( match ) ;
97- }
98- }
99- } else {
100- if ( ! this . notExisting . includes ( file ) ) this . notExisting . push ( file ) ;
101- }
102- } else {
103- if ( ! this . notExisting . includes ( file ) ) this . notExisting . push ( file ) ;
104- }
105- } else {
106- throw err
107- }
108- }
109- }
110- }
111-
112- clear ( ) {
113- this . files = [ ] ;
114- this . dirs = [ ] ;
115- this . notExisting = [ ] ;
116- }
117- }
118-
11942const { __dirname : __dirname$1 } = currentModulePaths ( ( typeof document === 'undefined' ? require ( 'u' + 'rl' ) . pathToFileURL ( __filename ) . href : ( _documentCurrentScript && _documentCurrentScript . tagName . toUpperCase ( ) === 'SCRIPT' && _documentCurrentScript . src || new URL ( 'index.cjs' , document . baseURI ) . href ) ) ) ;
12043
12144class JsdocCommand {
0 commit comments