tools/template.js
async function run () {
  if (options.help || Object.keys(options).length === 1) {
    showHelp()
    return
  }
  if (!options.name) {
    console.error('You need to input -n, --name argv')
    return
  }
  if (!options.title) {
    options.title = options.name.split('-').join(' ')
  }

  let content = (await fs.readFile(`${__dirname}/example.tpl`)).toString()
  content = content.replace(/@title@/, options.title || '')
    .replace(/@desc@/, options.desc || '')

  await fs.writeFile(`${__dirname}/../docs/examples/${options.name}.html`, content)
  console.info(`${options.name}.html`)

  let list = (await fs.readFile(`${__dirname}/../docs/_includes/example-list.md`)).toString()
  list += `<li><a href="../examples#${options.name}.html">${options.title}</a></li>\n`
  await fs.writeFile(`${__dirname}/../docs/_includes/example-list.md`, list)
}
async function run () {
  if (options.help || Object.keys(options).length === 1) {
    showHelp()
    return
  }
  if (!options.name) {
    console.error('You need to input -n, --name argv')
    return
  }
  if (!options.title) {
    options.title = options.name.split('-').join(' ')
  }

  let content = (await fs.readFile(`${__dirname}/example.tpl`)).toString()
  content = content.replace(/@title@/, options.title || '')
    .replace(/@desc@/, options.desc || '')

  await fs.writeFile(`${__dirname}/../docs/examples/${options.name}.html`, content)
  console.info(`${options.name}.html`)

  let list = (await fs.readFile(`${__dirname}/../docs/_includes/example-list.md`)).toString()
  list += `<li><a href="../examples#${options.name}.html">${options.title}</a></li>\n`
  await fs.writeFile(`${__dirname}/../docs/_includes/example-list.md`, list)
}
async function run ( ) { if ( options . help || Object . keys ( options ) . length === 1 ) { showHelp ( ) return } if ( ! options . name ) { console . error ( 'You need to input -n, --name argv' ) return } if ( ! options . title ) { options . title = options . name . split ( '-' ) . join ( ' ' ) } let content = ( await fs . readFile ( ` ${ __dirname } ` ) ) . toString ( ) content = content . replace ( / @title@ / , options . title || '' ) . replace ( / @desc@ / , options . desc || '' ) await fs . writeFile ( ` ${ __dirname } ${ options . name } ` , content ) console . info ( ` ${ options . name } ` ) let list = ( await fs . readFile ( ` ${ __dirname } ` ) ) . toString ( ) list += ` ${ options . name } ${ options . title } \n ` await fs . writeFile ( ` ${ __dirname } ` , list ) }
Perform document file writing.
@returns {void}
Perform document file writing .