summaryrefslogtreecommitdiff
path: root/std/prettier/ignore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/prettier/ignore.ts')
-rw-r--r--std/prettier/ignore.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/std/prettier/ignore.ts b/std/prettier/ignore.ts
new file mode 100644
index 000000000..ffada98de
--- /dev/null
+++ b/std/prettier/ignore.ts
@@ -0,0 +1,15 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+
+/**
+ * Parse the contents of the ignore file and return patterns.
+ * It can parse files like .gitignore/.npmignore/.prettierignore
+ * @param ignoreString
+ * @returns patterns
+ */
+export function parse(ignoreString: string): Set<string> {
+ const partterns = ignoreString
+ .split(/\r?\n/)
+ .filter(line => line.trim() !== "" && line.charAt(0) !== "#");
+
+ return new Set(partterns);
+}