-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial commit for node.js version #34
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const handlebars = require('handlebars') | ||
const mdpdf = require('mdpdf'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
const path = require('path'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
const fs = require('fs'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
const config = require('./config.json'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
const args = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
debug: process.argv.includes('--debug') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'process' is not defined. |
||
}; | ||
|
||
function generatePdf (fileNameWithoutExt) { | ||
const fileNameCompiled = fileNameWithoutExt + '__COMPILED.md'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
const fileCompiledPath = path.join(__dirname, `src/${fileNameCompiled}.md`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined. |
||
const content = fs.readFileSync(path.join(__dirname, `src/${fileNameWithoutExt}.md`), 'utf8'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined. |
||
const template = handlebars.compile(content); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
const result = template(config); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
|
||
fs.writeFileSync(fileCompiledPath, result); | ||
return mdpdf.convert({ | ||
source: fileCompiledPath, | ||
destination: path.join(__dirname, `/contracts/${fileNameWithoutExt}.pdf`), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined. |
||
debug: args.debug && path.join(__dirname, `/contracts/${fileNameWithoutExt}.html`), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined. |
||
styles: path.join(__dirname, 'md-style.css'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined. |
||
pdf: { | ||
format: 'A4', | ||
header: { | ||
height: '0mm' | ||
}, | ||
footer: { | ||
height: '0mm' | ||
}, | ||
border: { | ||
top: '20mm', | ||
left: '20mm', | ||
bottom: '20mm', | ||
right: '20mm' | ||
} | ||
} | ||
}) | ||
.then(() => fs.unlinkSync(fileCompiledPath)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6'). |
||
} | ||
|
||
generatePdf('cgv') | ||
.then(() => generatePdf('cp')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6'). |
||
.then(() => generatePdf('cga')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
'require' is not defined.
Missing semicolon.