-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from pascalre/48-error-in-recursively-sort
Enable sorting of files with unusual extension (#48)
- Loading branch information
Showing
15 changed files
with
89 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import * as fs from "fs" | ||
import * as glob from "glob" | ||
import { sync } from "glob" | ||
import { Settings } from "../settings" | ||
|
||
export class FileUtil { | ||
settings: Settings | ||
encoding: BufferEncoding = "utf-8" | ||
globOptions = {dot: true} | ||
|
||
constructor(settings = new Settings()) { | ||
this.settings = settings | ||
} | ||
|
||
getFilesWithExtensions(path: string): string[] { | ||
let files: string[] = [] | ||
for (const extension of this.settings.getExtensions()) { | ||
files = files.concat(sync(`${path}/**/*.${extension}`, this.globOptions)) | ||
} | ||
return files | ||
} | ||
|
||
readFile(file: string) { | ||
return fs.readFileSync(file, this.encoding).toString() | ||
} | ||
} | ||
|
||
/** | ||
* Returns all files in a directory and its subdirectories with extension .yml or .yaml | ||
* @param {string} uri Base URI | ||
* @returns {string[]} List of Yaml files | ||
*/ | ||
export function getYamlFilesInDirectory(uri: string): string[] { | ||
return glob.sync(uri + "/**/**.y?(a)ml") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters