Skip to content

Instantly share code, notes, and snippets.

@daffl
Created January 21, 2024 23:15
Show Gist options
  • Save daffl/19ff04a42c5066e172523a4f73297892 to your computer and use it in GitHub Desktop.
Save daffl/19ff04a42c5066e172523a4f73297892 to your computer and use it in GitHub Desktop.
Getting started with Pinion
import {
PinionContext,
toFile,
renderTemplate,
prompt
} from '@featherscloud/pinion'
interface Context extends PinionContext {
name: string
}
// The file content as a template string
const readme = ({ name }: Context) =>
`# Hello ${name}
Welcome to Pinion!
Copyright (c) ${new Date().getFullYear()}
`
// Export the generator and render the template
export const generate = (init: Context) =>
Promise.resolve(init)
.then(
prompt({
name: {
type: 'input',
message: 'What is your name?'
}
})
)
.then(renderTemplate(readme, toFile('readme.md')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment