-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11111 from DanielRuf/tests/use-husky
tests: use husky to run tests before commits and pushes
- Loading branch information
Showing
4 changed files
with
160 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const chalk = require('chalk') | ||
const spawn = require('child_process').spawn | ||
|
||
console.log(chalk.yellow('🐶 Checking tests before committing with Husky...')) | ||
|
||
const child = spawn('npm run test', [], { shell: true }) | ||
|
||
child.stdout.on('data', function (data) { | ||
process.stdout.write(data) | ||
}) | ||
|
||
child.on('exit', function (code) { | ||
if(code === 0){ | ||
console.log(chalk.yellow('🐶 ✓ Tests run well, we can commit...')) | ||
} else { | ||
console.log(chalk.yellow('🐶 ✗ Tests are failing, please fix them before committing.')) | ||
} | ||
}) | ||
|
||
child.on('error', function (err) { | ||
console.log(chalk.red(err)) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const chalk = require('chalk') | ||
const spawn = require('child_process').spawn | ||
|
||
console.log(chalk.yellow('🐶 Checking tests before pushing with Husky...')) | ||
|
||
const child = spawn('npm run test', [], { shell: true }) | ||
|
||
child.stdout.on('data', function (data) { | ||
process.stdout.write(data) | ||
}) | ||
|
||
child.on('exit', function (code) { | ||
if(code === 0){ | ||
console.log(chalk.yellow('🐶 ✓ Tests run well, we can push...')) | ||
} else { | ||
console.log(chalk.yellow('🐶 ✗ Tests are failing, please fix them before pushing.')) | ||
} | ||
}) | ||
|
||
child.on('error', function (err) { | ||
console.log(chalk.red(err)) | ||
}) |