@@ -82,7 +82,7 @@ function saveCache () {
8282// - Bad: blue (not visible on cmd.exe), grey (same color as background on
8383// Solarized Dark theme from <https://github.com/altercation/solarized>, see
8484// issue #160)
85- var colors = {
85+ const colors = {
8686 bold : [ 1 , 22 ] ,
8787 italic : [ 3 , 23 ] ,
8888 underline : [ 4 , 24 ] ,
@@ -100,7 +100,7 @@ var colors = {
100100
101101function stylizeWithColor ( str , color ) {
102102 if ( ! str ) { return '' }
103- var codes = colors [ color ]
103+ const codes = colors [ color ]
104104 if ( codes ) {
105105 return '\x1B[' + codes [ 0 ] + 'm' + str + '\x1B[' + codes [ 1 ] + 'm'
106106 } else {
@@ -131,9 +131,9 @@ function rot (moduleName, s) {
131131// I see in supported-technologies.asciidoc.
132132function loadSupportedDoc ( ) {
133133 const docPath = 'docs/supported-technologies.asciidoc'
134- var html = fs . readFileSync ( docPath , 'utf8' )
135- var rows = [ ]
136- var state = null // null | 'thead' | 'tbody'
134+ const html = fs . readFileSync ( docPath , 'utf8' )
135+ const rows = [ ]
136+ let state = null // null | 'thead' | 'tbody'
137137 html . split ( / \n / g) . forEach ( function ( line ) {
138138 if ( ! line . startsWith ( '|' ) ) {
139139 // no op
@@ -150,8 +150,8 @@ function loadSupportedDoc () {
150150 // Examples:
151151 // |https://www.npmjs.com/package/generic-pool[generic-pool] | ^2.0.0 \|\| ^3.1.0 |Used by a lot of ...
152152 // |https://www.npmjs.com/package/bluebird[bluebird] |>=2.0.0 <4.0.0 |
153- var escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24'
154- var cells = line
153+ const escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24'
154+ const cells = line
155155 . trim ( )
156156 . slice ( 1 ) // remove leading '|'
157157 . replace ( / \\ \| / g, escapePlaceholder )
@@ -177,7 +177,7 @@ function loadSupportedDoc () {
177177 // The entries in the "Frameworks" table use the names of internal links in
178178 // these docs. The anchor name is *sometimes* the same name as the npm
179179 // module, but sometimes not.
180- var results = [ ]
180+ const results = [ ]
181181 let match
182182 rows . forEach ( function ( row ) {
183183 if ( row [ 1 ] === 'N/A' ) {
@@ -187,7 +187,7 @@ function loadSupportedDoc () {
187187 if ( ! match ) {
188188 throw new Error ( `could not parse this table cell text from docs/supported-technologies.asciidoc: ${ JSON . stringify ( row [ 0 ] ) } ` )
189189 }
190- var moduleNames
190+ let moduleNames
191191 if ( match [ 1 ] === 'nextjs' ) {
192192 moduleNames = [ 'next' ]
193193 } else if ( match [ 2 ] === '@hapi/hapi' ) {
@@ -246,24 +246,24 @@ function getNpmInfo (name) {
246246
247247function bitrot ( moduleNames ) {
248248 log . debug ( { moduleNames } , 'bitrot' )
249- var tavYmls = [
249+ const tavYmls = [
250250 yaml . load ( fs . readFileSync ( '.tav.yml' , 'utf8' ) ) ,
251251 yaml . load ( fs . readFileSync ( './test/opentelemetry-bridge/.tav.yml' , 'utf8' ) ) ,
252252 yaml . load ( fs . readFileSync ( './test/opentelemetry-metrics/fixtures/.tav.yml' , 'utf8' ) ) ,
253253 yaml . load ( fs . readFileSync ( 'test/instrumentation/modules/next/a-nextjs-app/.tav.yml' , 'utf8' ) )
254254 ]
255- var supported = loadSupportedDoc ( )
255+ const supported = loadSupportedDoc ( )
256256
257257 // Merge into one data structure we can iterate through.
258- var rangesFromName = { }
259- var ensureKey = ( name ) => {
258+ const rangesFromName = { }
259+ const ensureKey = ( name ) => {
260260 if ( ! ( name in rangesFromName ) ) {
261261 rangesFromName [ name ] = { tavRanges : [ ] , supRanges : [ ] }
262262 }
263263 }
264264 tavYmls . forEach ( tavYml => {
265265 for ( const [ label , tavInfo ] of Object . entries ( tavYml ) ) {
266- var name = tavInfo . name || label
266+ const name = tavInfo . name || label
267267 ensureKey ( name )
268268 rangesFromName [ name ] . tavRanges . push ( tavInfo . versions )
269269 }
@@ -275,7 +275,7 @@ function bitrot (moduleNames) {
275275
276276 // Reduce to `moduleNames` if given.
277277 if ( moduleNames && moduleNames . length > 0 ) {
278- var allNames = Object . keys ( rangesFromName )
278+ const allNames = Object . keys ( rangesFromName )
279279 moduleNames . forEach ( name => {
280280 if ( ! ( name in rangesFromName ) ) {
281281 throw new Error ( `unknown module name: ${ name } (known module names: ${ allNames . join ( ', ' ) } )` )
@@ -290,15 +290,15 @@ function bitrot (moduleNames) {
290290 log . debug ( { rangesFromName } , 'rangesFromName' )
291291
292292 // Check each module name.
293- var namesToCheck = Object . keys ( rangesFromName ) . sort ( )
293+ const namesToCheck = Object . keys ( rangesFromName ) . sort ( )
294294 namesToCheck . forEach ( name => {
295- var npmInfo = getNpmInfo ( name )
295+ const npmInfo = getNpmInfo ( name )
296296 log . trace ( { name, 'dist-tags' : npmInfo [ 'dist-tags' ] , time : npmInfo . time } , 'npmInfo' )
297297
298298 // If the current latest version is in the supported and
299299 // tav ranges, then all is good.
300- var latest = npmInfo [ 'dist-tags' ] . latest
301- var tavGood = false
300+ const latest = npmInfo [ 'dist-tags' ] . latest
301+ let tavGood = false
302302 if ( EXCUSE_FROM_TAV [ name ] ) {
303303 tavGood = true
304304 } else {
@@ -309,7 +309,7 @@ function bitrot (moduleNames) {
309309 }
310310 }
311311 }
312- var supGood = false
312+ let supGood = false
313313 if ( EXCUSE_FROM_SUPPORTED_TECHNOLOGIES_DOC [ name ] ) {
314314 supGood = true
315315 } else {
@@ -324,7 +324,7 @@ function bitrot (moduleNames) {
324324 log . debug ( `latest ${ name } @${ latest } is in tav and supported ranges (a good thing)` )
325325 return
326326 }
327- var issues = [ ]
327+ const issues = [ ]
328328 if ( ! tavGood ) {
329329 issues . push ( `is not in .tav.yml ranges (${ rangesFromName [ name ] . tavRanges . join ( ', ' ) } )` )
330330 }
@@ -351,15 +351,15 @@ const options = [
351351]
352352
353353function main ( argv ) {
354- var parser = dashdash . createParser ( { options : options } )
354+ const parser = dashdash . createParser ( { options : options } )
355355 try {
356356 var opts = parser . parse ( argv )
357357 } catch ( e ) {
358358 console . error ( 'help: error: %s' , e . message )
359359 process . exit ( 1 )
360360 }
361361 if ( opts . help ) {
362- var help = parser . help ( ) . trimRight ( )
362+ const help = parser . help ( ) . trimRight ( )
363363 process . stdout . write ( `Synopsis:
364364 dev-utils/bitrot.js [OPTIONS]
365365
0 commit comments