( path: string )
| 8 | } |
| 9 | |
| 10 | export function listUnencodedSassVariables( |
| 11 | path: string |
| 12 | ): Promise<ReadonlyArray<SassVariable>> { |
| 13 | return new Promise<ReadonlyArray<SassVariable>>((resolve, reject) => { |
| 14 | const unencodedVariables = new Array<SassVariable>() |
| 15 | |
| 16 | const lineReader = readline.createInterface({ |
| 17 | input: fs.createReadStream(path), |
| 18 | }) |
| 19 | |
| 20 | let lineNumber = 0 |
| 21 | |
| 22 | lineReader.on('line', (line: string) => { |
| 23 | lineNumber++ |
| 24 | |
| 25 | const index = line.indexOf('$', 0) |
| 26 | |
| 27 | if (index > -1) { |
| 28 | unencodedVariables.push({ |
| 29 | fileName: path, |
| 30 | lineNumber, |
| 31 | text: line, |
| 32 | }) |
| 33 | } |
| 34 | }) |
| 35 | |
| 36 | lineReader.on('close', () => { |
| 37 | resolve(unencodedVariables) |
| 38 | }) |
| 39 | |
| 40 | lineReader.on('error', (err: Error) => { |
| 41 | reject(err) |
| 42 | }) |
| 43 | }) |
| 44 | } |
no test coverage detected