(filename: string, findPattern: string | RegExp)
| 10 | * @return Boolean of success that findPattern was in file. |
| 11 | */ |
| 12 | export async function exists(filename: string, findPattern: string | RegExp): Promise<boolean> { |
| 13 | // sanity check the filename |
| 14 | if (!is(String, filename) || filesystem.isNotFile(filename)) return false |
| 15 | |
| 16 | // sanity check the findPattern |
| 17 | const patternIsString = typeof findPattern === 'string' |
| 18 | if (!(findPattern instanceof RegExp) && !patternIsString) return false |
| 19 | |
| 20 | // read from jetpack -- they guard against a lot of the edge |
| 21 | // cases and return nil if problematic |
| 22 | const contents = filesystem.read(filename) |
| 23 | |
| 24 | // only let the strings pass |
| 25 | if (!is(String, contents)) return false |
| 26 | |
| 27 | // do the appropriate check |
| 28 | return isPatternIncluded(contents, findPattern) |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Updates a text file or json config file. Async. |
nothing calls this directly
no test coverage detected
searching dependent graphs…