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

fix(husky): revert stdin tty workaround of #766 for npm #825

Merged
merged 1 commit into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

yarn commitlint --edit $1
8 changes: 8 additions & 0 deletions .husky/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
command_exists () {
command -v "$1" >/dev/null 2>&1
}

# Workaround for Windows 10, Git Bash and Yarn
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

yarn lint && yarn test -u && git add ./packages/*/test/snapshots/*
4 changes: 3 additions & 1 deletion packages/cna-template/template/nuxt/.husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
<%_ if (pm === 'yarn') { _%>
. "$(dirname "$0")/common.sh"
<%_ } _%>

<%= pmRun === 'yarn' ? 'yarn' : 'npx' %> commitlint --edit $1
<%= pm === 'yarn' ? 'yarn' : 'npx --no-install' %> commitlint --edit $1
2 changes: 0 additions & 2 deletions packages/cna-template/template/nuxt/.husky/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<%_ if (isWindows === true) { _%>
command_exists () {
command -v "$1" >/dev/null 2>&1
}
Expand All @@ -7,4 +6,3 @@ command_exists () {
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
<%_ } _%>
4 changes: 3 additions & 1 deletion packages/cna-template/template/nuxt/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
<%_ if (pm === 'yarn') { _%>
. "$(dirname "$0")/common.sh"
<%_ } _%>

<%= pmRun === 'yarn' ? 'yarn' : 'npx' %> lint-staged
<%= pm === 'yarn' ? 'yarn' : 'npx --no-install' %> lint-staged
6 changes: 2 additions & 4 deletions packages/create-nuxt-app/lib/saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const validate = require('validate-npm-package-name')
const pkg = require('./package')

const cnaTemplateDir = join(dirname(require.resolve('cna-template/package.json')))
const isWindows = process.platform === 'win32'
const templateDir = join(cnaTemplateDir, 'template')
const frameworksDir = join(templateDir, 'frameworks')
const addExecutable = filename => new Promise(
Expand Down Expand Up @@ -41,8 +40,7 @@ module.exports = {
edge,
pm,
pmRun,
content,
isWindows
content
}
},
actions () {
Expand Down Expand Up @@ -72,7 +70,7 @@ module.exports = {
'.husky/.gitignore': husky,
'.husky/commit-msg': commitlint,
'.husky/pre-commit': lintStaged,
'.husky/common.sh': husky
'.husky/common.sh': husky && this.answers.pm === 'yarn'
}
}]

Expand Down