mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-22 17:23:22 +01:00
new project script tweaks
This commit is contained in:
parent
996058032e
commit
b86da120d1
@ -7,14 +7,27 @@ const ora = require('ora')
|
|||||||
const templatePath = path.join(__dirname, 'new-project.yml')
|
const templatePath = path.join(__dirname, 'new-project.yml')
|
||||||
const template = fs.readFileSync(templatePath).toString()
|
const template = fs.readFileSync(templatePath).toString()
|
||||||
|
|
||||||
const title = process.argv[2]
|
const spinner = ora('Adding new project').start()
|
||||||
const titleSlug = slugify(title)
|
|
||||||
const spinner = ora(`Adding '${title}'.`).start()
|
|
||||||
|
|
||||||
const newContents = template.replace('TITLE', title).replace('SLUG', titleSlug)
|
if (!process.argv[2]) {
|
||||||
|
spinner.fail('Use the format `npm run new -- Title of project`')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = process.argv[2]
|
||||||
|
spinner.text = `Adding '${title}'.`
|
||||||
|
|
||||||
|
const titleSlug = slugify(title, { lower: true })
|
||||||
const projects = path.join(__dirname, '..', 'data', 'projects.yml')
|
const projects = path.join(__dirname, '..', 'data', 'projects.yml')
|
||||||
|
const newContents = template
|
||||||
|
.split('TITLE')
|
||||||
|
.join(title)
|
||||||
|
.split('SLUG')
|
||||||
|
.join(titleSlug)
|
||||||
|
|
||||||
prepend(projects, newContents, error => {
|
prepend(projects, newContents, error => {
|
||||||
if (error) throw error
|
if (error) {
|
||||||
|
spinner.fail(error)
|
||||||
|
}
|
||||||
spinner.succeed(`Added '${title}' to top of projects.yml file.`)
|
spinner.succeed(`Added '${title}' to top of projects.yml file.`)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user