From ee39cf9c5fb6faa4859238c3c9719f6211d3fe5b Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Thu, 27 Sep 2018 15:15:32 +0900 Subject: [PATCH] `husky-upgrade` replace GIT_PARAMS with HUSKY_GIT_PARAMS (#360) --- 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 08088140b..cfc23bd24 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}`) } })