feat(cli): add standalone CLI

This commit is contained in:
Rafael Bardini 2021-03-06 14:46:55 +01:00
parent c703065447
commit 807acf6473
3 changed files with 11 additions and 13 deletions

View File

@ -1,12 +0,0 @@
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const { render } = require('..')
const resume = require('resume-schema/sample.resume.json')
const dest = path.resolve(__dirname, '../public');
const html = render(resume)
fs.mkdirSync(dest, { recursive: true })
fs.writeFileSync(path.resolve(dest, 'index.html'), html)

8
bin/cli.js Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
const fs = require('fs')
const { render } = require('..')
const resume = JSON.parse(fs.readFileSync(process.stdin.fd, 'utf-8'))
const html = render(resume)
process.stdout.write(html)

View File

@ -12,14 +12,16 @@
},
"license": "MIT",
"author": "Rafael Bardini",
"bin": "bin/cli.js",
"files": [
"bin",
"index.js",
"resume.hbs",
"partials/*.hbs",
"style.css"
],
"scripts": {
"build:demo": "./bin/build-demo",
"build:demo": "mkdir public && cat node_modules/resume-schema/sample.resume.json | ./bin/cli.js > public/index.html",
"format": "prettier --write .",
"lint": "eslint .",
"postinstall": "husky install",