summaryrefslogtreecommitdiff
path: root/cli/fs_util.rs
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2021-09-23 21:49:25 +0530
committerGitHub <noreply@github.com>2021-09-23 21:49:25 +0530
commitc5442abc237b8e11491afb09dbaa80a66488fc7b (patch)
tree319a2df2095008a32bc9847c542bf1b96053473f /cli/fs_util.rs
parente0c858fa27af07f163f5d18bb0401d0f0069dd3c (diff)
feat(cli/fmt): support more markdown extensions (#12195)
Diffstat (limited to 'cli/fs_util.rs')
-rw-r--r--cli/fs_util.rs39
1 files changed, 37 insertions, 2 deletions
diff --git a/cli/fs_util.rs b/cli/fs_util.rs
index 446c16f27..86dfb5b10 100644
--- a/cli/fs_util.rs
+++ b/cli/fs_util.rs
@@ -106,7 +106,19 @@ pub fn is_supported_ext_fmt(path: &Path) -> bool {
if let Some(ext) = get_extension(path) {
matches!(
ext.as_str(),
- "ts" | "tsx" | "js" | "jsx" | "mjs" | "md" | "json" | "jsonc"
+ "ts"
+ | "tsx"
+ | "js"
+ | "jsx"
+ | "mjs"
+ | "json"
+ | "jsonc"
+ | "md"
+ | "mkd"
+ | "mkdn"
+ | "mdwn"
+ | "mdown"
+ | "markdown"
)
} else {
false
@@ -143,7 +155,20 @@ pub fn is_supported_test_path(path: &Path) -> bool {
/// Checks if the path has an extension Deno supports for tests.
pub fn is_supported_test_ext(path: &Path) -> bool {
if let Some(ext) = get_extension(path) {
- matches!(ext.as_str(), "ts" | "tsx" | "js" | "jsx" | "mjs" | "md")
+ matches!(
+ ext.as_str(),
+ "ts"
+ | "tsx"
+ | "js"
+ | "jsx"
+ | "mjs"
+ | "md"
+ | "mkd"
+ | "mkdn"
+ | "mdwn"
+ | "mdown"
+ | "markdown"
+ )
} else {
false
}
@@ -320,6 +345,11 @@ mod tests {
assert!(!is_supported_ext_fmt(Path::new("tests/subdir/redirects")));
assert!(is_supported_ext_fmt(Path::new("README.md")));
assert!(is_supported_ext_fmt(Path::new("readme.MD")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mkd")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mkdn")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mdwn")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mdown")));
+ assert!(is_supported_ext_fmt(Path::new("readme.markdown")));
assert!(is_supported_ext_fmt(Path::new("lib/typescript.d.ts")));
assert!(is_supported_ext_fmt(Path::new("testdata/001_hello.js")));
assert!(is_supported_ext_fmt(Path::new("testdata/002_hello.ts")));
@@ -342,6 +372,11 @@ mod tests {
assert!(!is_supported_test_ext(Path::new("tests/subdir/redirects")));
assert!(is_supported_test_ext(Path::new("README.md")));
assert!(is_supported_test_ext(Path::new("readme.MD")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mkd")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mkdn")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mdwn")));
+ assert!(is_supported_ext_fmt(Path::new("readme.mdown")));
+ assert!(is_supported_ext_fmt(Path::new("readme.markdown")));
assert!(is_supported_test_ext(Path::new("lib/typescript.d.ts")));
assert!(is_supported_test_ext(Path::new("testdata/001_hello.js")));
assert!(is_supported_test_ext(Path::new("testdata/002_hello.ts")));