1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-23 09:45:56 +01:00
blog/scripts/new/index.ts
Matthias Kretschmann 05ad0470c2
migrate to biome (#944)
* migrate to biome

* cleanup

* fix

* use tsx

* script tweaks

* fix test runs

* path tweaks
2024-07-27 21:15:05 +01:00

27 lines
784 B
TypeScript

import path from 'node:path'
import ora from 'ora'
import { createArticlePost } from './createArticlePost.js'
import { createPhotoPost } from './createPhotoPost.js'
const postsPath = path.join('.', 'content', 'articles')
const photosPath = path.join('.', 'content', 'photos')
const spinner = ora('Adding new post').start()
if (!process.argv[2]) {
spinner.fail(
'Use the format `npm run new "Title of post"` or `npm run new photo path/to/photo.jpg`'
)
}
const isPhoto = process.argv[2] === 'photo'
if (isPhoto) {
const photo = process.argv[3]
const photoTitle = process.argv[4]
createPhotoPost(photosPath, spinner, photo, photoTitle)
} else {
const title = process.argv[2]
const newDate = process.argv[3]
createArticlePost(postsPath, spinner, title, newDate)
}