How to use the @adonisjs/sink.TemplateFile function in @adonisjs/sink

To help you get started, we’ve selected a few @adonisjs/sink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adonisjs / adonis-cli / src / Services / ResourceBuilder.ts View on Github external
public async make () {
    const destinationDir = join(this._projectRoot, this._location, this._basedir)
    const fileNameForLogs = join(this._basedir, this._location, this._fileName)
    await ensureDir(destinationDir)

    const resource = new TemplateFile(destinationDir, this._fileName, this._template)

    /**
     * Return early when resource file already exists
     */
    if (resource.exists()) {
      fancyLogs.error(`${fileNameForLogs} file already exists`)
      return
    }

    resource
      .apply(Object.assign(this._data, { resourceName: this._resourceName }))
      .commit()

    fancyLogs.create(fileNameForLogs)
  }
}
github AdonisCommunity / create-adonis-ts-app / tasks / copyTemplates.ts View on Github external
.forEach((name: string) => {
      const outputFileName = name.replace(/\.txt$/, '.ts')
      const src = join(__dirname, '..', 'templates', state.boilerplate, name)
      new TemplateFile(absPath, outputFileName, src).apply({}).commit()
      logger.create(outputFileName)
    })
}