src/files.js
async function generateFilesFromTemplate({ name, path, templatesPath }) {
  try {
    const files = glob.sync('**/*', { cwd: templatesPath, nodir: true })
    const config = getConfig(null, templatesPath, templatesPath)
    const outputPath = config.noMkdir ? `${path}` : `${path}/${name}`
    files.map(async (templateFileName) => {
      // Get the template content
      const content = await readFile(templatesPath, templateFileName)
      const replaced = replaceKeys(content, name)

      // Exist ?
      const newFileName = replaceKeys(templateFileName, name)
      // Write the new file with the new content
      fs.outputFile(`${outputPath}/${newFileName}`, replaced)
    })
  } catch (e) {
    Logger.error(e.message)
  }
}
async function generateFilesFromTemplate({ name, path, templatesPath }) {
  try {
    const files = glob.sync('**/*', { cwd: templatesPath, nodir: true })
    const config = getConfig(null, templatesPath, templatesPath)
    const outputPath = config.noMkdir ? `${path}` : `${path}/${name}`
    files.map(async (templateFileName) => {
      // Get the template content
      const content = await readFile(templatesPath, templateFileName)
      const replaced = replaceKeys(content, name)

      // Exist ?
      const newFileName = replaceKeys(templateFileName, name)
      // Write the new file with the new content
      fs.outputFile(`${outputPath}/${newFileName}`, replaced)
    })
  } catch (e) {
    Logger.error(e.message)
  }
}
async function generateFilesFromTemplate ( { name , path , templatesPath } ) { try { const files = glob . sync ( '**/*' , { cwd : templatesPath , nodir : true } ) const config = getConfig ( null , templatesPath , templatesPath ) const outputPath = config . noMkdir ? ` ${ path } ` : ` ${ path } ${ name } ` files . map ( async ( templateFileName ) => { // Get the template content const content = await readFile ( templatesPath , templateFileName ) const replaced = replaceKeys ( content , name ) // Exist ? const newFileName = replaceKeys ( templateFileName , name ) // Write the new file with the new content fs . outputFile ( ` ${ outputPath } ${ newFileName } ` , replaced ) } ) } catch ( e ) { Logger . error ( e . message ) } }
Generate component files from custom templates folder
Get every single file in the folder
@param {string} the name of the component used to create folder and file
@param {string} where the component folder is created
@param {string} where the custom templates are
Generate component files from custom templates folder Get every single file in the folder