1- import * as path from 'path' ;
2- import { OwnershipEngine } from '../lib/OwnershipEngine' ;
3- import { OwnedFile } from '../lib/OwnedFile' ;
4- import { OUTPUT_FORMAT } from '../lib/types' ;
1+ import { OUTPUT_FORMAT , writeOwnedFile , writeStats } from '../lib/writers' ;
52import { calcFileStats } from '../lib/stats' ;
6- import { writeOwnedFile , writeStats } from '../lib/writers' ;
7- import { readDirRecursively } from '../lib/dir' ;
3+ import { getFileOwnership } from '../lib/ownership' ;
84
95interface AuditOptions {
106 codeowners : string ;
@@ -16,7 +12,7 @@ interface AuditOptions {
1612}
1713
1814export const audit = async ( options : AuditOptions ) => {
19- const files = await getFilesWithOwnership ( options ) ;
15+ const files = await getFileOwnership ( options ) ;
2016
2117 if ( options . stats ) {
2218 const stats = calcFileStats ( files ) ;
@@ -34,23 +30,3 @@ export const audit = async (options: AuditOptions) => {
3430 }
3531 }
3632} ;
37-
38- const getFilesWithOwnership = async ( options : AuditOptions ) : Promise < OwnedFile [ ] > => {
39- const engine = OwnershipEngine . FromCodeownersFile ( options . codeowners ) ;
40-
41- let filePaths = await readDirRecursively ( options . dir , [ '.git' ] ) ;
42-
43- if ( options . root ) { // We need to re-add the root so that later ops can find the file
44- filePaths = filePaths . map ( filePath => path . join ( options . root , filePath ) ) ;
45- }
46-
47- filePaths . sort ( ) ;
48-
49- const files : OwnedFile [ ] = [ ] ;
50-
51- for ( const filePath of filePaths ) {
52- files . push ( await OwnedFile . FromPath ( filePath , engine ) ) ;
53- }
54-
55- return files ;
56- } ;
0 commit comments