-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
함수에 파라미터 타입과 리턴 타입 지정
- Loading branch information
Showing
4 changed files
with
28 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,48 +1,48 @@ | ||
const { exec } = require("child_process"); | ||
|
||
class Committer { | ||
static logger = (code, command) => | ||
export default class Committer { | ||
static logger = (code: number, command: string) => | ||
//if success code value is 0 | ||
code === 0 | ||
? console.log(`'${command}' command is successed. with exit code:${code}`) | ||
: console.error(`'${command}' command is failed. with exit code:${code}`); | ||
|
||
static commit(file) { | ||
static commit(file: string): void { | ||
//0. check cur dir is git directory | ||
|
||
//1. check file is valid_ | ||
//first) file is located at this dir | ||
//second) check file's located dir also | ||
|
||
//2. git add | ||
const getGitAddCmdStr = (file) => `git add ${file}`; | ||
const getGitAddCmdStr = (file: string) => `git add ${file}`; | ||
|
||
const addStdout = exec( | ||
`${getGitAddCmdStr(file)}`, | ||
(error, stdout, stderr) => { | ||
(error: Error, stdout: string, stderr: string) => { | ||
// console.error(error); //this value is 'null' | ||
// console.error(stdout); //this value is '' | ||
// console.error(stderr); //this value is '' | ||
} | ||
); | ||
addStdout.on("exit", (code) => Committer.logger(code, "git add")); | ||
addStdout.on("exit", (code: number) => Committer.logger(code, "git add")); | ||
|
||
//3. git commit -m | ||
const getCommitMessage = (file) => `Add ${file}`; | ||
const getCommitMessage = (file: string) => `Add ${file}`; | ||
const getGitCommitCmdStr = `git commit -m "${getCommitMessage(file)}"`; | ||
|
||
const commitStdout = exec(getGitCommitCmdStr); | ||
commitStdout.on("exit", (code) => Committer.logger(code, "git commit")); | ||
commitStdout.on("exit", (code: number) => | ||
Committer.logger(code, "git commit") | ||
); | ||
|
||
//4. how to know git commit is succes? | ||
} | ||
|
||
static push() { | ||
static push(): void { | ||
const gitPushCmdStr = "git push"; | ||
|
||
const pushStdout = exec(gitPushCmdStr); | ||
pushStdout.on("exit", (code) => Committer.logger(code, "git push")); | ||
pushStdout.on("exit", (code: number) => Committer.logger(code, "git push")); | ||
} | ||
} | ||
|
||
module.exports = Committer; |
This file contains 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
This file contains 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
This file contains 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