@@ -29,36 +29,34 @@ module.exports = yargs
29
29
desc : 'has new remote commits' ,
30
30
handler : ( ) => {
31
31
run ( 'git rev-parse --is-inside-work-tree' )
32
- . then ( ( ) =>
33
- run ( 'git remote -v update' )
34
- . then ( ( ) =>
35
- Promise . all ( [
36
- run ( 'git rev-parse @' ) ,
37
- run ( 'git rev-parse @{u}' ) ,
38
- run ( 'git merge-base @ @{u}' ) ,
39
- ] )
40
- . then ( values => {
41
- const [ { stdout : $local } , { stdout : $remote } , { stdout : $base } ] = values ;
32
+ . then ( ( ) => run ( 'git remote -v update' )
33
+ . then ( ( ) => Promise . all ( [
34
+ run ( 'git rev-parse @' ) ,
35
+ run ( 'git rev-parse @{u}' ) ,
36
+ run ( 'git merge-base @ @{u}' ) ,
37
+ ] )
38
+ . then ( values => {
39
+ const [ { stdout : $local } , { stdout : $remote } , { stdout : $base } ] = values ;
42
40
43
- if ( $local === $remote ) {
44
- console . log ( chalk . green ( '✔ Repo is up-to-date!' ) ) ;
45
- }
46
- else if ( $local === $base ) {
47
- console . log ( chalk . red ( '⊘ Error' ) , 'You need to pull, there are new commits.' ) ;
48
- process . exit ( 1 ) ;
49
- }
50
- } )
51
- . catch ( err => {
52
- if ( err . message . includes ( 'no upstream configured ' ) ) {
53
- console . log ( chalk . yellow ( '⚠ Warning' ) , 'No upstream. Is this a new branch?' ) ;
54
- return ;
55
- }
56
-
57
- console . log ( chalk . yellow ( '⚠ Warning' ) , err . message ) ;
58
- } ) )
41
+ if ( $local === $remote ) {
42
+ console . log ( chalk . green ( '✔ Repo is up-to-date!' ) ) ;
43
+ }
44
+ else if ( $local === $base ) {
45
+ console . log ( chalk . red ( '⊘ Error' ) , 'You need to pull, there are new commits.' ) ;
46
+ process . exit ( 1 ) ;
47
+ }
48
+ } )
59
49
. catch ( err => {
60
- throw new Error ( err ) ;
50
+ if ( err . message . includes ( 'no upstream configured ' ) ) {
51
+ console . log ( chalk . yellow ( '⚠ Warning' ) , 'No upstream. Is this a new branch?' ) ;
52
+ return ;
53
+ }
54
+
55
+ console . log ( chalk . yellow ( '⚠ Warning' ) , err . message ) ;
61
56
} ) )
57
+ . catch ( err => {
58
+ throw new Error ( err ) ;
59
+ } ) )
62
60
. catch ( ( ) => {
63
61
console . log ( 'not under git' ) ;
64
62
} ) ;
@@ -67,21 +65,19 @@ module.exports = yargs
67
65
. command ( {
68
66
command : 'update' ,
69
67
desc : 'run `npm update` if package.json has changed' ,
70
- handler : ( ) => {
71
- return run ( 'git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD' )
72
- . then ( ( { stdout } ) => {
73
- if ( stdout . match ( 'package.json' ) ) {
74
- console . log ( chalk . yellow ( '▼ Updating...' ) ) ;
75
- exec ( 'npm update' ) . stdout . pipe ( process . stdout ) ;
76
- }
77
- else {
78
- console . log ( chalk . green ( '✔ Nothing to update' ) ) ;
79
- }
80
- } )
81
- . catch ( err => {
82
- throw new Error ( err ) ;
83
- } ) ;
84
- } ,
68
+ handler : ( ) => run ( 'git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD' )
69
+ . then ( ( { stdout } ) => {
70
+ if ( stdout . match ( 'package.json' ) ) {
71
+ console . log ( chalk . yellow ( '▼ Updating...' ) ) ;
72
+ exec ( 'npm update' ) . stdout . pipe ( process . stdout ) ;
73
+ }
74
+ else {
75
+ console . log ( chalk . green ( '✔ Nothing to update' ) ) ;
76
+ }
77
+ } )
78
+ . catch ( err => {
79
+ throw new Error ( err ) ;
80
+ } ) ,
85
81
} )
86
82
. demandCommand ( )
87
83
. help ( )
0 commit comments