-
Notifications
You must be signed in to change notification settings - Fork 8
싸인 재활용하는 옵션 추가 #5
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
Open
dohvis
wants to merge
2
commits into
jen6:main
Choose a base branch
from
dohvis:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ var multer = require('multer'); | |
| var upload = multer(); | ||
| const express = require('express') | ||
| var path = require('path'); | ||
| const os = require('os'); | ||
|
|
||
| var appDir = path.dirname(require.main.filename); | ||
|
|
||
|
|
@@ -136,7 +137,6 @@ async function drawUserInfo(page, userInfo) { | |
|
|
||
| async function createSheet(fileName, userInfo, workInfos, year, imgData) { | ||
| const pdfDoc = await PDFDocument.load(file) | ||
|
|
||
| pdfDoc.registerFontkit(fontkit); | ||
| const font = await pdfDoc.embedFont(fontFile) | ||
| const signature = await pdfDoc.embedPng(imgData) | ||
|
|
@@ -243,14 +243,39 @@ const sleep = (ms) => { | |
| }) | ||
| } | ||
|
|
||
| async function getSignature() { | ||
| function getSignatureFilePath() { | ||
| const tmpDir = os.tmpdir(); | ||
| filePath = path.join(tmpDir, "workDiary-signature.png"); | ||
| return filePath; | ||
| } | ||
| function getSignatureFromFile() { | ||
| const filePath = getSignatureFilePath(); | ||
| if(fs.existsSync(filePath)) { | ||
| return fs.readFileSync(filePath, { encoding: "utf-8" }) | ||
| } | ||
| return ""; | ||
| } | ||
|
|
||
| function writeSignatureFile(data) { | ||
| const filePath = getSignatureFilePath(); | ||
| fs.writeFileSync(filePath, data); | ||
| } | ||
|
|
||
| async function getSignature(isReuseSign) { | ||
| var data = ""; | ||
| if (isReuseSign === true) { | ||
|
Owner
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. early return 으로 해주시면 가독성이 좀 올라갈것 같습니다 if (isReuseSign === false) {
return
}
~~ |
||
| data = getSignatureFromFile(); | ||
| if (data !== "") { | ||
| return data; | ||
| } | ||
| } | ||
|
|
||
| const app = express() | ||
| app.use(bodyParser.json()); // for parsing application/json | ||
| app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded | ||
| app.use(upload.array()); // for parsing multipart/form-data | ||
| app.use(express.static(appDir+'/public')) | ||
|
|
||
| var data = "" | ||
|
|
||
|
|
||
| app.post('/', (req, res) =>{ | ||
| res.send("Hello") | ||
|
|
@@ -270,11 +295,11 @@ async function getSignature() { | |
| } | ||
|
|
||
| server.close() | ||
| writeSignatureFile(data); | ||
| return data | ||
| } | ||
|
|
||
| async function main(){ | ||
| const signature = await getSignature() | ||
| var myArgs = process.argv.slice(2); | ||
| if (myArgs.length == 0) { | ||
| console.log("Usage : workDiary 'csv file path' '[year]'") | ||
|
|
@@ -285,6 +310,9 @@ async function main(){ | |
| if (typeof year === "undefined") { | ||
| year = new Date().getFullYear().toString(); | ||
| } | ||
| const reuseSign = myArgs.filter((arg) => arg === "--reuse-sign"); | ||
|
Owner
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. 이거 위에 example이랑 Usage 에도 추가해주실 수 있을까요? |
||
| const isReuseSign = reuseSign.length > 0; | ||
| const signature = await getSignature(isReuseSign); | ||
| const [userInfo, workInfos] = await parseCSV(csvFileName); | ||
|
|
||
| for (var i = 0; i < workInfos.length; i++) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
최근 제가 사용하는 cli 툴들은 대부분
~/.config/application-name이런식으로 생성해서 사용하는것 같습니다.tmp 폴더도 상관없긴하지만 이왕이면 폴더를 생성하거나 하면 좋을듯 합니다