]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
chore: use Node.js for precommit and prepush output
authorDaniel Ruf <daniel@daniel-ruf.de>
Sun, 1 Apr 2018 20:26:26 +0000 (22:26 +0200)
committerDaniel Ruf <daniel@daniel-ruf.de>
Sun, 1 Apr 2018 23:41:35 +0000 (01:41 +0200)
package.json
script/husky-precommit [deleted file]
script/husky-precommit.js [new file with mode: 0644]
script/husky-prepush [deleted file]
script/husky-prepush.js [new file with mode: 0644]

index e1879eb3db2fea2ce5e0fabee424525632ac72c1..978f9cfd2d5703e35dba4183ce4285f023aba4a1 100644 (file)
@@ -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 (executable)
index 9c15613..0000000
+++ /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 (file)
index 0000000..cdb83d0
--- /dev/null
@@ -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 (executable)
index a5c7e63..0000000
+++ /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 (file)
index 0000000..571031f
--- /dev/null
@@ -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