File tree 1 file changed +6
-25
lines changed
1 file changed +6
-25
lines changed Original file line number Diff line number Diff line change 1
- #! /bin/bash
2
- #
3
- # * Check changed js files using jshint and jscs.
4
- # * Runs tests.
5
- #
1
+ #!/usr/bin/env node
6
2
7
- PATCH_FILE=" working-tree.patch"
8
- NPM_BIN=" ./node_modules/.bin"
3
+ var spawn = require ( 'child_process' ) . spawn ;
4
+ var exec = require ( 'child_process' ) . execSync ;
5
+ var gitCachedFiles = exec ( 'git diff --cached --name-only --diff-filter=ACMR' ) . toString ( ) . trim ( ) ;
9
6
10
- function cleanup {
11
- exit_code=$?
12
- if [ -f " $PATCH_FILE " ]; then
13
- git apply " $PATCH_FILE " 2> /dev/null
14
- rm " $PATCH_FILE "
15
- fi
16
- exit $exit_code
7
+ if ( gitCachedFiles ) {
8
+ spawn ( 'npm' , [ 'test' ] , { stdio : 'inherit' } ) . on ( 'close' , process . exit . bind ( process ) ) ;
17
9
}
18
-
19
- trap cleanup EXIT SIGINT SIGHUP
20
-
21
- # Cancel any changes to the working tree that are not going to be committed
22
- git diff > " $PATCH_FILE "
23
- git checkout -- .
24
-
25
- git_cached_files=$( git diff --cached --name-only --diff-filter=ACMR | grep " \.js$" )
26
- if [ " $git_cached_files " ]; then
27
- npm test --silent || exit 1
28
- fi
You can’t perform that action at this time.
0 commit comments