Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 807546d

Browse files
authored
fix(husky): stdin is not a tty in git bash (#766)
1 parent a77b284 commit 807546d

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
3+
. "$(dirname "$0")/common.sh"
34

45
<%= pmRun %> commitlint --edit $1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<%_ if (isWindows === true) { _%>
2+
command_exists () {
3+
command -v "$1" >/dev/null 2>&1
4+
}
5+
6+
# Workaround for Windows 10, Git Bash and Yarn
7+
if command_exists winpty && test -t 1; then
8+
exec < /dev/tty
9+
fi
10+
<%_ } _%>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
3+
. "$(dirname "$0")/common.sh"
34

45
<%= pmRun %> lint-staged

packages/create-nuxt-app/lib/saofile.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const validate = require('validate-npm-package-name')
55
const pkg = require('./package')
66

77
const cnaTemplateDir = join(dirname(require.resolve('cna-template/package.json')))
8+
const isWindows = process.platform === 'win32'
89
const templateDir = join(cnaTemplateDir, 'template')
910
const frameworksDir = join(templateDir, 'frameworks')
1011
const addExecutable = filename => new Promise(
@@ -25,7 +26,6 @@ module.exports = {
2526
const content = this.answers.features.includes('content')
2627
const pm = this.answers.pm === 'yarn' ? 'yarn' : 'npm'
2728
const pmRun = this.answers.pm === 'yarn' ? 'yarn' : 'npm run'
28-
2929
const { cliOptions = {} } = this.sao.opts
3030
const edge = cliOptions.edge ? '-edge' : ''
3131

@@ -41,7 +41,8 @@ module.exports = {
4141
edge,
4242
pm,
4343
pmRun,
44-
content
44+
content,
45+
isWindows
4546
}
4647
},
4748
actions () {
@@ -58,6 +59,7 @@ module.exports = {
5859
const eslint = linter.includes('eslint')
5960
const lintStaged = eslint && linter.includes('lintStaged')
6061
const commitlint = linter.includes('commitlint')
62+
const husky = lintStaged || commitlint
6163

6264
const actions = [{
6365
type: 'add',
@@ -67,9 +69,10 @@ module.exports = {
6769
'static/icon.png': 'features.includes("pwa")',
6870
'content/hello.md': 'features.includes("content")',
6971
'pages/content.vue': 'features.includes("content")',
70-
'.husky/.gitignore': lintStaged || commitlint,
72+
'.husky/.gitignore': husky,
7173
'.husky/commit-msg': commitlint,
72-
'.husky/pre-commit': lintStaged
74+
'.husky/pre-commit': lintStaged,
75+
'.husky/common.sh': husky
7376
}
7477
}]
7578

packages/create-nuxt-app/test/snapshots/index.test.js.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,7 @@ Generated by [AVA](https://avajs.dev).
22912291
'.gitignore',
22922292
'.husky/.gitignore',
22932293
'.husky/commit-msg',
2294+
'.husky/common.sh',
22942295
'.husky/pre-commit',
22952296
'.prettierrc',
22962297
'README.md',
@@ -2778,6 +2779,7 @@ Generated by [AVA](https://avajs.dev).
27782779
'.gitignore',
27792780
'.husky/.gitignore',
27802781
'.husky/commit-msg',
2782+
'.husky/common.sh',
27812783
'README.md',
27822784
'assets/README.md',
27832785
'commitlint.config.js',
26 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)