1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-06-30 05:31:44 +02:00
portfolio/scripts/new-project.js

21 lines
672 B
JavaScript
Raw Normal View History

2018-05-14 01:50:11 +02:00
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.`)
})