From 7bbc273b036783474235dc48cf21bdea7821226f Mon Sep 17 00:00:00 2001 From: Masafumi Koba Date: Thu, 27 Sep 2018 03:06:49 +0900 Subject: [PATCH] `husky-upgrade` replace GIT_PARAMS with HUSKY_GIT_PARAMS --- src/upgrader/__tests__/index.ts | 3 +++ src/upgrader/index.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/upgrader/__tests__/index.ts b/src/upgrader/__tests__/index.ts index dd0e80bc0..acf1fdb90 100644 --- a/src/upgrader/__tests__/index.ts +++ b/src/upgrader/__tests__/index.ts @@ -12,6 +12,7 @@ describe('upgrade', () => { filename, JSON.stringify({ scripts: { + commitmsg: 'echo $GIT_PARAMS GIT_PARAMS HUSKY_GIT_PARAMS', precommit: 'npm test' } }), @@ -23,6 +24,8 @@ describe('upgrade', () => { expect(JSON.parse(fs.readFileSync(filename, 'utf-8'))).toEqual({ husky: { hooks: { + 'commit-msg': + 'echo $HUSKY_GIT_PARAMS HUSKY_GIT_PARAMS HUSKY_GIT_PARAMS', 'pre-commit': 'npm test' } }, diff --git a/src/upgrader/index.ts b/src/upgrader/index.ts index 6be6b952e..d40134bd7 100644 --- a/src/upgrader/index.ts +++ b/src/upgrader/index.ts @@ -51,7 +51,10 @@ export default function upgrade(cwd: string) { if (script) { delete pkg.scripts[name] const newName = hookList[name] - pkg.husky.hooks[newName] = script + pkg.husky.hooks[newName] = script.replace( + /\bGIT_PARAMS\b/g, + 'HUSKY_GIT_PARAMS' + ) console.log(`moved scripts.${name} to husky.hooks.${newName}`) } })