summaryrefslogtreecommitdiff
path: root/std/prettier/ignore.ts
blob: 08a8239842906c0a34d1f7f7f6f95876c774ee29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Copyright 2018-2020 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);
}