from-data-to-pdf
Version:
This library converts html files, URL and character string from html files to PDF files or PDF buffer.
51 lines (45 loc) • 1.42 kB
JavaScript
const { exec } = require("child_process");
const fs = require("fs");
main();
async function main() {
const res = (await t()).output.split("\n");
const resLength = res.length;
const arr = [];
let lines = [];
for (let i = 0; i < resLength; i++) {
res[i] = res[i].split("--").join("\"");
if (res[i].slice(-1) === "}" && lines.length === 0) {
arr.push(JSON.parse(res[i]));
continue;
}
else if (res[i].slice(-1) === "}") {
lines.push(res[i]);
lines = lines.join("-s-");
lines = JSON.parse(lines);
lines.message = lines.message.split("-s-");
lines.message.pop();
arr.push(lines);
lines = [];
continue;
} else {
lines.push(res[i]);
}
}
console.log(arr);
}
function t() {
return new Promise((resolve, rej) => {
exec(
'git log --pretty=format:{--commit--:--%H--,--author--:--%an--,--author_email--:--%ae--,--date--:--%ad--,--message--:--%B--}',
(error, stdout, stderr) => {
const cmdRes = {
succeed: !!stdout,
output: stdout || stderr,
error,
};
resolve(cmdRes);
}
);
});
}