(indentStr?: string)
| 248 | } |
| 249 | |
| 250 | indent(indentStr?: string): this { |
| 251 | if (!arguments.length) { |
| 252 | indentStr = this.getIndentString() |
| 253 | } |
| 254 | |
| 255 | if (indentStr === '') |
| 256 | return this // noop |
| 257 | |
| 258 | let trailingNewline = !this.intro || this.intro.slice(-1) === '\n' |
| 259 | |
| 260 | this.sources.forEach((source, i) => { |
| 261 | const separator = source.separator !== undefined ? source.separator : this.separator |
| 262 | const indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator)) |
| 263 | |
| 264 | source.content.indent(indentStr, { |
| 265 | exclude: source.indentExclusionRanges, |
| 266 | indentStart, // : trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator ) |
| 267 | }) |
| 268 | |
| 269 | trailingNewline = source.content.lastChar() === '\n' |
| 270 | }) |
| 271 | |
| 272 | if (this.intro) { |
| 273 | this.intro |
| 274 | = indentStr |
| 275 | + this.intro.replace(/^[^\n]/gm, (match, index) => { |
| 276 | return index > 0 ? indentStr + match : match |
| 277 | }) |
| 278 | } |
| 279 | |
| 280 | return this |
| 281 | } |
| 282 | |
| 283 | prepend(str: string): this { |
| 284 | this.intro = str + this.intro |
no test coverage detected