Shuunen/repo-checker

View on GitHub
src/files/npmrc.file.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { FileBase } from '../file'

// eslint-disable-next-line no-restricted-syntax
export class NpmRcFile extends FileBase {
  private checkPrePost() {
    if (!this.data.hasTaskPrefix) return
    const isOk = this.couldContains('enable-pre-post-scripts option', /enable-pre-post-scripts=true/u)
    if (!isOk && this.canFix) this.fileContent += '\nenable-pre-post-scripts=true'
  }

  public async start() {
    const hasFile = await this.checkFileExists('.npmrc', true)
    if (!hasFile) return
    await this.inspectFile('.npmrc')
    this.checkPrePost()
  }
}