diff options
author | Axetroy <axetroy.dev@gmail.com> | 2019-11-27 00:07:40 +0800 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-11-26 08:07:39 -0800 |
commit | 2a348144c6932f749dfa28b6b8590d6df1c083f2 (patch) | |
tree | 778e1e289aa61056f188d346c92bf189d3b5bf50 /std/prettier/ignore.ts | |
parent | c016684653df45c3c3bc88d79dfc295ea5c6426f (diff) |
feat: add ignore parser for std/prettier (#3399)
Diffstat (limited to 'std/prettier/ignore.ts')
-rw-r--r-- | std/prettier/ignore.ts | 15 |
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); +} |