File tree Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Original file line number Diff line number Diff line change 55const fs = require ( 'fs' )
66const nopt = require ( 'nopt' )
77const path = require ( 'path' )
8- const pretty = require ( '../lib/format-pretty' )
98const formatTap = require ( '../lib/format-tap' )
109const Validator = require ( '../lib' )
1110const Tap = require ( '../lib/tap' )
@@ -110,22 +109,6 @@ if (parsed.tap) {
110109
111110} else {
112111 // no --flags used, defaults to --validate-metadata
113- v . on ( 'commit' , ( c ) => {
114- pretty ( c . commit , c . messages , v )
115- run ( )
116- } )
117-
118- function run ( ) {
119- if ( ! args . length ) {
120- process . exitCode = v . errors
121- return
122- }
123- const sha = args . shift ( )
124- utils . load ( sha , ( err , data ) => {
125- if ( err ) throw err
126- v . lint ( data )
127- } )
128- }
129-
130- run ( )
112+ utils . validateMetadata ( v , args )
113+ return
131114}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const exec = require('child_process').exec
44const http = require ( 'http' )
55const https = require ( 'https' )
66const url = require ( 'url' )
7+ const pretty = require ( '../lib/format-pretty' )
78const chalk = require ( 'chalk' )
89const CHECK = chalk . green ( '✔' )
910const X = chalk . red ( '✖' )
@@ -102,3 +103,24 @@ exports.loadPatch = function loadPatch(uri, cb) {
102103 } )
103104 } ) . on ( 'error' , cb )
104105}
106+
107+ exports . validateMetadata = function ( validator , args ) {
108+ validator . on ( 'commit' , ( c ) => {
109+ pretty ( c . commit , c . messages , validator )
110+ run ( )
111+ } )
112+
113+ function run ( ) {
114+ if ( ! args . length ) {
115+ process . exitCode = validator . errors
116+ return
117+ }
118+ const sha = args . shift ( )
119+ exports . load ( sha , ( err , data ) => {
120+ if ( err ) throw err
121+ validator . lint ( data )
122+ } )
123+ }
124+
125+ run ( )
126+ }
You can’t perform that action at this time.
0 commit comments