-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(husky): remove no longer needed npm exec
since 9.1.1
#1760
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependabot
bot
added
dependencies
Pull requests that update a dependency file
javascript
Pull requests that update Javascript code
labels
Jul 22, 2024
Diff between husky 9.0.11 and 9.1.1diff --git a/husky b/husky
index v9.0.11..v9.1.1 100644
--- a/husky
+++ b/husky
@@ -1,20 +1,27 @@
#!/usr/bin/env sh
+# shellcheck disable=SC1090
[ "$HUSKY" = "2" ] && set -x
-h="${0##*/}"
-s="${0%/*/*}/$h"
+n=$(basename "$0")
+s=$(dirname "$(dirname "$0")")/$n
[ ! -f "$s" ] && exit 0
-for f in "${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" "$HOME/.huskyrc"; do
- # shellcheck disable=SC1090
- [ -f "$f" ] && . "$f"
-done
+if [ -f "$HOME/.huskyrc" ]; then
+ echo "husky - '~/.huskyrc' is DEPRECATED, please move your code to ~/.config/husky/init.sh"
+fi
+i="${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh"
+[ -f "$i" ] && . "$i"
\ No newline at end of file
[ "${HUSKY-}" = "0" ] && exit 0
-sh -e "$s" "$@"
-c=$?
-
-[ $c != 0 ] && echo "husky - $h script failed (code $c)"
-[ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
-exit $c
+c=0
+h() {
+ [ $c = 0 ] && return
+ [ $c != 0 ] && echo "husky - $n script failed (code $c)"
+ [ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
+ exit 1
+}
+trap 'c=$?; h' EXIT
+set -e
+PATH=node_modules/.bin:$PATH
+. "$s"
\ No newline at end of file
diff --git a/package.json b/package.json
index v9.0.11..v9.1.1 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,6 @@
{
"name": "husky",
- "version": "9.0.11",
+ "version": "9.1.1",
+ "type": "module",
"description": "Modern native Git hooks",
"keywords": [
@@ -16,7 +17,7 @@
"author": "typicode",
"bin": {
- "husky": "bin.mjs"
+ "husky": "bin.js"
},
- "exports": "./index.mjs",
+ "exports": "./index.js",
"engines": {
"node": ">=18"
diff --git a/bin.mjs b/bin.mjs
deleted file mode 100755
index v9.0.11..v9.1.1
--- a/bin.mjs
+++ b/bin.mjs
@@ -1,26 +0,0 @@
-#!/usr/bin/env node
-import f, { writeFileSync as w } from 'fs'
-import i from './index.mjs'
-
-let p, a, n, s, o, d
-
-p = process
-a = p.argv[2]
-
-if (a == 'init') {
- n = 'package.json'
- s = f.readFileSync(n)
- o = JSON.parse(s)
- ;(o.scripts ||= {}).prepare = 'husky'
- w(n, JSON.stringify(o, 0, /\t/.test(s) ? '\t' : 2) + '\n')
- p.stdout.write(i())
- try { f.mkdirSync('.husky') } catch {}
- w('.husky/pre-commit', p.env.npm_config_user_agent.split('/')[0] + ' test\n')
- p.exit()
-}
-
-d = c => console.error(`${c} command is deprecated`)
-if (['add', 'set', 'uninstall'].includes(a)) { d(a); p.exit(1) }
-if (a == 'install') d(a)
-
-p.stdout.write(i(a == 'install' ? undefined : a))
\ No newline at end of file
diff --git a/index.mjs b/index.mjs
deleted file mode 100644
index v9.0.11..v9.1.1
--- a/index.mjs
+++ b/index.mjs
@@ -1,23 +0,0 @@
-import c from 'child_process'
-import f, { writeFileSync as w } from 'fs'
-import p from 'path'
-
-let l = [ 'pre-commit', 'prepare-commit-msg', 'commit-msg', 'post-commit', 'applypatch-msg', 'pre-applypatch', 'post-applypatch', 'pre-rebase', 'post-rewrite', 'post-checkout', 'post-merge', 'pre-push', 'pre-auto-gc' ]
-
-export default (d = '.husky') => {
- if (process.env.HUSKY === '0') return 'HUSKY=0 skip install'
- if (d.includes('..')) return '.. not allowed'
- if (!f.existsSync('.git')) return `.git can't be found`
-
- let _ = (x = '') => p.join(d, '_', x)
- let { status: s, stderr: e } = c.spawnSync('git', ['config', 'core.hooksPath', `${d}/_`])
- if (s == null) return 'git command not found'
- if (s) return '' + e
-
- f.mkdirSync(_(), { recursive: true })
- w(_('.gitignore'), '*')
- f.copyFileSync(new URL('husky', import.meta.url), _('h'))
- l.forEach(h => w(_(h), `#!/usr/bin/env sh\n. "\${0%/*}/h"`, { mode: 0o755 }))
- w(_('husky.sh'), '')
- return ''
-}
\ No newline at end of file
diff --git a/index.d.mts b/index.d.mts
deleted file mode 100644
index v9.0.11..v9.1.1
--- a/index.d.mts
+++ b/index.d.mts
@@ -1,1 +0,0 @@
-export default function (dir?: string): string;
\ No newline at end of file
diff --git a/bin.js b/bin.js
new file mode 100755
index v9.0.11..v9.1.1
--- a/bin.js
+++ b/bin.js
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+import f, { writeFileSync as w } from 'fs'
+import i from './index.js'
+
+let p, a, n, s, o, d
+
+p = process
+a = p.argv[2]
+
+if (a == 'init') {
+ n = 'package.json'
+ s = f.readFileSync(n)
+ o = JSON.parse(s)
+ ;(o.scripts ||= {}).prepare = 'husky'
+ w(n, JSON.stringify(o, 0, /\t/.test(s) ? '\t' : 2) + '\n')
+ p.stdout.write(i())
+ try { f.mkdirSync('.husky') } catch {}
+ w('.husky/pre-commit', p.env.npm_config_user_agent?.split('/')[0] ?? 'npm' + ' test\n')
+ p.exit()
+}
+
+d = c => console.error(`${c} command is DEPRECATED`)
+if (['add', 'set', 'uninstall'].includes(a)) { d(a); p.exit(1) }
+if (a == 'install') d(a)
+
+p.stdout.write(i(a == 'install' ? undefined : a))
\ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index v9.0.11..v9.1.1
--- a/index.js
+++ b/index.js
@@ -0,0 +1,33 @@
+import c from 'child_process'
+import f, { readdir, writeFileSync as w } from 'fs'
+import p from 'path'
+
+let l = [ 'pre-commit', 'prepare-commit-msg', 'commit-msg', 'post-commit', 'applypatch-msg', 'pre-applypatch', 'post-applypatch', 'pre-rebase', 'post-rewrite', 'post-checkout', 'post-merge', 'pre-push', 'pre-auto-gc' ],
+ re = /^(#!\/usr\/bin\/env sh|\. "\$\(dirname -- "\$0"\)\/_\/husky\.sh")\r?\n/gm
+
+export default (d = '.husky') => {
+ if (process.env.HUSKY === '0') return 'HUSKY=0 skip install'
+ if (d.includes('..')) return '.. not allowed'
+ if (!f.existsSync('.git')) return `.git can't be found`
+
+ let _ = (x = '') => p.join(d, '_', x)
+ let { status: s, stderr: e } = c.spawnSync('git', ['config', 'core.hooksPath', `${d}/_`])
+ if (s == null) return 'git command not found'
+ if (s) return '' + e
+
+ f.rmSync(_('husky.sh'), { force: true })
+ l.forEach(h => {
+ let hp = p.join(d, h)
+ if (!f.existsSync(hp)) return
+ let prev = f.readFileSync(hp, 'utf8')
+ let next = prev.replace(re, '')
+ if (prev !== next) console.log(`husky - removed deprecated code from ${hp}`)
+ f.writeFileSync(hp, next)
+ })
+
+ f.mkdirSync(_(), { recursive: true })
+ w(_('.gitignore'), '*')
+ f.copyFileSync(new URL('husky', import.meta.url), _('h'))
+ l.forEach(h => w(_(h), `#!/usr/bin/env sh\n. "\$(dirname "\$0")/h"`, { mode: 0o755 }))
+ return ''
+}
\ No newline at end of file
diff --git a/index.d.ts b/index.d.ts
new file mode 100644
index v9.0.11..v9.1.1
--- a/index.d.ts
+++ b/index.d.ts
@@ -0,0 +1,1 @@
+export default function (dir?: string): string;
\ No newline at end of file
Command detailsnpm diff [email protected] [email protected] --diff-unified=2 See also the Reported by ybiquitous/[email protected] (Node.js 22.5.1 and npm 10.8.2) |
dependabot
bot
force-pushed
the
dependabot/npm_and_yarn/husky-9.1.1
branch
2 times, most recently
from
July 22, 2024 02:30
32cb939
to
f784682
Compare
@dependabot rebase |
Bumps [husky](https://github.com/typicode/husky) from 9.0.11 to 9.1.1. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](typicode/husky@v9.0.11...v9.1.1) --- updated-dependencies: - dependency-name: husky dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
dependabot
bot
force-pushed
the
dependabot/npm_and_yarn/husky-9.1.1
branch
from
July 22, 2024 02:35
f784682
to
337180e
Compare
ybiquitous
changed the title
build(deps): bump husky from 9.0.11 to 9.1.1
feat(husky): remove no longer needed Jul 22, 2024
npm exec
since 9.1.1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
dependencies
Pull requests that update a dependency file
javascript
Pull requests that update Javascript code
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bumps husky from 9.0.11 to 9.1.1.
Release notes
Sourced from husky's releases.
... (truncated)
Commits
2968998
9.1.1902749b
docsa25c6ce
update vitepressbbfe8e3
Merge branch 'ccerrillo-fix-windows-path'eb54845
automatically rm deprecated codee8badd7
Small typo fix (#1471)a24ccbc
9.1.09085a9d
v9.1.0 (#1467)b9f5889
automatically rm deprecated code71e5dcb
Small typo fix (#1471)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditions
will show all of the ignore conditions of the specified dependency@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)