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

Commit 1520453

Browse files
authored
fix(husky): revert stdin tty workaround of #766 for npm (#825)
1 parent 93297e5 commit 1520453

File tree

7 files changed

+18
-8
lines changed

7 files changed

+18
-8
lines changed

.husky/commit-msg

+1
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
yarn commitlint --edit $1

.husky/common.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
command_exists () {
2+
command -v "$1" >/dev/null 2>&1
3+
}
4+
5+
# Workaround for Windows 10, Git Bash and Yarn
6+
if command_exists winpty && test -t 1; then
7+
exec < /dev/tty
8+
fi

.husky/pre-commit

+1
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
yarn lint && yarn test -u && git add ./packages/*/test/snapshots/*
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
3+
<%_ if (pm === 'yarn') { _%>
34
. "$(dirname "$0")/common.sh"
5+
<%_ } _%>
46

5-
<%= pmRun === 'yarn' ? 'yarn' : 'npx' %> commitlint --edit $1
7+
<%= pm === 'yarn' ? 'yarn' : 'npx --no-install' %> commitlint --edit $1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<%_ if (isWindows === true) { _%>
21
command_exists () {
32
command -v "$1" >/dev/null 2>&1
43
}
@@ -7,4 +6,3 @@ command_exists () {
76
if command_exists winpty && test -t 1; then
87
exec < /dev/tty
98
fi
10-
<%_ } _%>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
3+
<%_ if (pm === 'yarn') { _%>
34
. "$(dirname "$0")/common.sh"
5+
<%_ } _%>
46

5-
<%= pmRun === 'yarn' ? 'yarn' : 'npx' %> lint-staged
7+
<%= pm === 'yarn' ? 'yarn' : 'npx --no-install' %> lint-staged

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ 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'
98
const templateDir = join(cnaTemplateDir, 'template')
109
const frameworksDir = join(templateDir, 'frameworks')
1110
const addExecutable = filename => new Promise(
@@ -41,8 +40,7 @@ module.exports = {
4140
edge,
4241
pm,
4342
pmRun,
44-
content,
45-
isWindows
43+
content
4644
}
4745
},
4846
actions () {
@@ -72,7 +70,7 @@ module.exports = {
7270
'.husky/.gitignore': husky,
7371
'.husky/commit-msg': commitlint,
7472
'.husky/pre-commit': lintStaged,
75-
'.husky/common.sh': husky
73+
'.husky/common.sh': husky && this.answers.pm === 'yarn'
7674
}
7775
}]
7876

0 commit comments

Comments
 (0)