Skip to content

Commit

Permalink
fix(yarn): install hook to skip when image pack
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelfimov committed Oct 8, 2024
1 parent 2ed3dcf commit 4eff880
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .yarn/releases/yarn.cjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions yarn/cli/dist/yarn.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions yarn/pack-utils/src/pack.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const pack = async (
report: Report,
destination: PortablePath
): Promise<void> => {
process.env.IMAGE_PACK = true

const cache = await Cache.find(configuration, { immutable: true })

await project.restoreInstallState()
Expand Down
32 changes: 18 additions & 14 deletions yarn/plugin-tools/src/hooks/after-all-installed.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,29 @@ const hooksExists = (): boolean => {
}

export const afterAllInstalled = async (project: Project): Promise<void> => {
const target = ppath.join(project.cwd, '.config/husky')
if (process.env.IMAGE_PACK) return

await xfs.writeFilePromise(ppath.join(target, 'commit-msg'), hook('yarn commit message lint'), {
mode: 0o755,
})
try {
const target = ppath.join(project.cwd, '.config/husky')

await xfs.writeFilePromise(ppath.join(target, 'pre-commit'), hook('yarn commit staged'), {
mode: 0o755,
})
await xfs.writeFilePromise(ppath.join(target, 'commit-msg'), hook('yarn commit message lint'), {
mode: 0o755,
})

await xfs.writeFilePromise(
ppath.join(target, 'prepare-commit-msg'),
hook('yarn commit message $@'),
{ mode: 0o755 }
)
await xfs.writeFilePromise(ppath.join(target, 'pre-commit'), hook('yarn commit staged'), {
mode: 0o755,
})

const { error } = git(['config', 'core.hooksPath', target])
await xfs.writeFilePromise(
ppath.join(target, 'prepare-commit-msg'),
hook('yarn commit message $@'),
{ mode: 0o755 }
)

if (error) {
const { error } = git(['config', 'core.hooksPath', target])

if (error) throw error
} catch (error) {
throw error
}
}

0 comments on commit 4eff880

Please sign in to comment.