Skip to content

Commit

Permalink
Merge pull request #325 from ottofeller/husky-hooks-file-structure
Browse files Browse the repository at this point in the history
PLA-245 Change file structure for husky hooks
  • Loading branch information
gvidon authored Aug 2, 2023
2 parents 676a221 + e9464ae commit ac860a4
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/common/git/husky/add-husky.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {NodeProject} from 'projen/lib/javascript'
import {WithGitHooks} from '../with-git-hooks'
import {checkCargo} from './check-cargo'
import {commitMessage} from './commit-message'
import {WithGitHooks} from './with-git-hooks'

export const addHusky = (project: NodeProject, options: WithGitHooks): void => {
project.addDevDeps('husky')
Expand Down
15 changes: 15 additions & 0 deletions src/common/git/husky/check-cargo-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface CheckCargoOptions {
/**
* Perform a code formatting step
*
* @default true
*/
readonly isFormatting?: boolean

/**
* Path to the cargo
*
* @default '.'
*/
readonly workingDirectory?: string
}
2 changes: 1 addition & 1 deletion src/common/git/husky/check-cargo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as path from 'path'
import type {NodeProject} from 'projen/lib/javascript'
import {AssetFile} from '../../files/AssetFile'
import type {CheckCargoOptions} from './check-cargo-options'
import {destinationFolder, sourceFolder, templateFile, templateString} from './template-path'
import type {CheckCargoOptions} from './with-git-hooks'

export const checkCargo = (project: NodeProject, options: CheckCargoOptions) => {
const commands: Array<string> = ['cargo check']
Expand Down
17 changes: 17 additions & 0 deletions src/common/git/husky/husky-rule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type {CheckCargoOptions} from './check-cargo-options'

export interface HuskyRule {
/**
* Include pre-commit hook with `cargo check` command.
*
* @default undefined
*/
readonly checkCargo?: CheckCargoOptions

/**
* Include commit message hook.
*
* @default true
*/
readonly commitMsg?: boolean
}
3 changes: 2 additions & 1 deletion src/common/git/husky/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './add-husky'
export * from './with-git-hooks'
export * from './check-cargo-options'
export * from './husky-rule'
47 changes: 0 additions & 47 deletions src/common/git/husky/with-git-hooks.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/common/git/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './gitignore'
export * from './husky'
export * from './with-git-hooks'
17 changes: 17 additions & 0 deletions src/common/git/with-git-hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type {HuskyRule} from './husky'

export interface WithGitHooks {
/**
* Include husky for git hook management.
*
* @default false
*/
readonly hasGitHooks?: boolean

/**
* Include a default git hook that checks commit message.
*
* @default { commitMsg: true }
*/
readonly huskyRules?: HuskyRule
}

0 comments on commit ac860a4

Please sign in to comment.