Giter Site home page Giter Site logo

proof-of-concept-git-hook's Introduction

인터페이스 파일 생성 자동화를 위한 git hook

동기

Node.js + Typescript로 서버/클라이언트를 개발하다보면 서로 비슷한 파일을 작성하게 된다.

가장 좋은 예시는 Rest API 요청/응답에 대한 interface인데, 서버쪽에서 정의한 명세가 조금 바뀐다거나 하는 일이 자주 발생하곤 한다.

그러던 중 git의 pre-commit 훅을 이용해서 특정 디렉토리의 파일이 변하면 목적 디렉토리에 같은 파일을 복사하는 스크립트가 있으면 어떨까하는 생각이 들었다.

구현

git hook을 좀 더 쉽게 사용하기 위해 husky를 사용하였으며, 그 덕분에 복잡한 쉘스크립트를 사용하지 않고도 훅을 작성할 수 있었다.

로직은 git diff 커맨드를 통해 변화된 파일의 이름을 받아온 뒤, 정규표현식을 통해 특정 디렉토리의 파일이 변했는지를 체크한 뒤 그렇다면 목표 디렉토리에 복사한다.

기능은 코드 생성기와 비슷하다고 볼 수 있는데 사람이 수동으로 작업하다보면 잊어버릴 수 있는 부분을 잘 캐치해준다.

만약 import 경로 등이 다르다면 조금 유용성이 떨어질 수 있다.

proof-of-concept-git-hook's People

Contributors

leejh3224 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.