From c353e2685d087105ba5465c3dc2a7385ab630844 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Sun, 1 Apr 2018 22:26:26 +0200 Subject: [PATCH] chore: use Node.js for precommit and prepush output --- package.json | 2 +- script/husky-precommit | 10 ---------- script/husky-precommit.js | 22 ++++++++++++++++++++++ script/husky-prepush | 10 ---------- script/husky-prepush.js | 22 ++++++++++++++++++++++ 5 files changed, 45 insertions(+), 21 deletions(-) delete mode 100755 script/husky-precommit create mode 100644 script/husky-precommit.js delete mode 100755 script/husky-prepush create mode 100644 script/husky-prepush.js diff --git a/package.json b/package.json index e1879eb3d..978f9cfd2 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "deploy:prep": "gulp deploy:prep", "deploy:docs": "gulp deploy:docs", "deploy:beta": "gulp deploy:beta", - "precommit": "./script/husky-precommit", + "precommit": "node ./script/husky-precommit.js", "prepush": "./script/husky-prepush" }, "dependencies": { diff --git a/script/husky-precommit b/script/husky-precommit deleted file mode 100755 index 9c1561358..000000000 --- a/script/husky-precommit +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -{ - echo -e "\033[33m🐶  Checking tests before committing with Husky...\033[0m" && - npm run test && - echo -e "\033[33m🐶  ✓ Tests run well, we can commit...\033[0m" -} || { - echo -e "\033[33m🐶  ✗ Tests are failing, please fix them before committing.\033[0m" - exit 1 -} diff --git a/script/husky-precommit.js b/script/husky-precommit.js new file mode 100644 index 000000000..cdb83d078 --- /dev/null +++ b/script/husky-precommit.js @@ -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(code, '🐶 ✓ 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)) +}) \ No newline at end of file diff --git a/script/husky-prepush b/script/husky-prepush deleted file mode 100755 index a5c7e63f9..000000000 --- a/script/husky-prepush +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -{ - echo -e "\033[33m🐶  Checking tests before pushing with Husky...\033[0m" && - npm run test && - echo -e "\033[33m🐶  ✓ Tests run well, we can push...\033[0m" -} || { - echo -e "\033[33m🐶  ✗ Tests are failing, please fix them before pushing.\033[0m" - exit 1 -} diff --git a/script/husky-prepush.js b/script/husky-prepush.js new file mode 100644 index 000000000..571031fa4 --- /dev/null +++ b/script/husky-prepush.js @@ -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(code, '🐶 ✓ 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)) +}) \ No newline at end of file -- 2.47.2