File tree 3 files changed +12
-7
lines changed 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ import {
11
11
filterForVersion ,
12
12
addToGitignore ,
13
13
replaceGitignore ,
14
- removeDirectory
14
+ removeDirectory ,
15
+ isVersionString
15
16
} from './util.js' ;
16
17
import applyNodeChanges from './applyNodeChanges.js' ;
17
18
import { chromiumGit , v8Deps } from './constants.js' ;
@@ -38,14 +39,13 @@ export default function majorUpdate() {
38
39
} ;
39
40
} ;
40
41
41
- const versionReg = / ^ \d + ( \. \d + ) + $ / ;
42
42
function checkoutBranch ( ) {
43
43
return {
44
44
title : 'Checkout V8 branch' ,
45
45
task : async ( ctx ) => {
46
46
let version = ctx . branch ;
47
47
await ctx . execGitV8 ( 'checkout' , 'origin/main' ) ;
48
- if ( ! versionReg . test ( version ) ) {
48
+ if ( ! isVersionString ( version ) ) {
49
49
// try to get the latest tag
50
50
const res = await ctx . execGitV8 (
51
51
'tag' ,
@@ -54,7 +54,7 @@ function checkoutBranch() {
54
54
'--sort' ,
55
55
'version:refname'
56
56
) ;
57
- const tags = res . stdout . split ( '\n' ) . filter ( tag => versionReg . test ( tag ) ) ;
57
+ const tags = res . stdout . split ( '\n' ) . filter ( isVersionString ) ;
58
58
const lastTag = tags [ tags . length - 1 ] ;
59
59
if ( lastTag ) version = lastTag ;
60
60
if ( version . split ( '.' ) . length === 3 ) {
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { execa } from 'execa';
6
6
import { Listr } from 'listr2' ;
7
7
8
8
import { getCurrentV8Version } from './common.js' ;
9
+ import { isVersionString } from './util.js' ;
9
10
10
11
export default function minorUpdate ( ) {
11
12
return {
@@ -34,7 +35,7 @@ function getLatestV8Version() {
34
35
cwd : ctx . v8Dir ,
35
36
encoding : 'utf8'
36
37
} ) ;
37
- const tags = toSortedArray ( result . stdout ) ;
38
+ const tags = filterAndSortTags ( result . stdout ) ;
38
39
ctx . latestVersion = tags [ 0 ] ;
39
40
}
40
41
} ;
@@ -79,10 +80,10 @@ async function applyPatch(ctx, latestStr) {
79
80
}
80
81
}
81
82
82
- function toSortedArray ( tags ) {
83
+ function filterAndSortTags ( tags ) {
83
84
return tags
84
85
. split ( / [ \r \n ] + / )
85
- . filter ( ( tag ) => tag !== '' )
86
+ . filter ( isVersionString )
86
87
. map ( ( tag ) => tag . split ( '.' ) )
87
88
. sort ( sortVersions ) ;
88
89
}
Original file line number Diff line number Diff line change @@ -56,3 +56,7 @@ export function removeDirectory(path) {
56
56
return fs . rmdir ( path , { recursive : true } ) ;
57
57
}
58
58
}
59
+
60
+ export function isVersionString ( str ) {
61
+ return / ^ \d + ( \. \d + ) + $ / . test ( str ) ;
62
+ }
You can’t perform that action at this time.
0 commit comments