1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-23 01:29:41 +01:00
portfolio/scripts/new-project.js

21 lines
672 B
JavaScript

const fs = require('fs')
const path = require('path')
const prepend = require('prepend')
const slugify = require('slugify')
const ora = require('ora')
const templatePath = path.join(__dirname, 'new-project.yml')
const template = fs.readFileSync(templatePath).toString()
const title = process.argv[2]
const titleSlug = slugify(title)
const spinner = ora(`Adding '${title}'.`).start()
const newContents = template.replace('TITLE', title).replace('SLUG', titleSlug)
const projects = path.join(__dirname, '..', 'data', 'projects.yml')
prepend(projects, newContents, error => {
if (error) throw error
spinner.succeed(`Added '${title}' to top of projects.yml file.`)
})