FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
binaryen.js/scripts/version.js at update-version-script-1 · AssemblyScript/binaryen.js · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AssemblyScript
/
binaryen.js
Public
Notifications
You must be signed in to change notification settings
Fork
54
Star
404
Code
Issues
8
Pull requests
5
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
binaryen.js
/
scripts
/
version.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (58 loc) · 1.77 KB
Breadcrumbs
binaryen.js
/
scripts
/
version.js
Copy path
File metadata and controls
69 lines (58 loc) · 1.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import
simpleGit
from
"simple-git"
;
import
semver
from
"semver"
;
import
dateFormat
from
"dateformat"
;
import
path
from
'path'
;
import
{
fileURLToPath
}
from
'url'
;
const
__dirname
=
path
.
dirname
(
fileURLToPath
(
import
.
meta
.
url
)
)
;
const
resolve
=
(
...
args
)
=>
path
.
resolve
(
__dirname
,
...
args
)
;
const
MAX_TAGS_LIMIT
=
64
;
function
isGreater
(
a
,
b
)
{
const
cmp
=
semver
.
compare
(
semver
.
coerce
(
a
)
,
semver
.
coerce
(
b
)
)
;
return
cmp
===
0
?
a
.
includes
(
"nightly"
)
&&
!
b
.
includes
(
"nightly"
)
:
cmp
>
0
;
}
const
createRepo
=
(
path
,
regex
,
mapVersion
)
=>
(
{
git
:
simpleGit
(
path
)
,
filter
:
tag
=>
{
const
match
=
regex
.
exec
(
tag
)
;
return
match
?
{
tag
,
version
:
mapVersion
(
match
)
,
}
:
null
;
}
}
)
;
// see: https://github.com/WebAssembly/binaryen/issues/1156
const
src
=
createRepo
(
resolve
(
'../binaryen'
)
,
/
^
v
e
r
s
i
o
n
_
(
\d
+
)
(?:
_
.
*
)
?
$
/
,
(
[
,
maj
]
)
=>
`
${
maj
}
.0.0`
)
;
const
dst
=
createRepo
(
resolve
(
'..'
)
,
/
^
v
(
\d
+
\.
\d
+
\.
\d
+
)
(?:
\-
|
$
)
/
,
(
[
,
ver
]
)
=>
ver
)
;
async
function
latest
(
repo
)
{
try
{
const
tagsRaw
=
await
repo
.
git
.
raw
(
[
'tag'
,
'--sort=-v:refname'
]
)
;
const
allTags
=
tagsRaw
.
split
(
'\n'
)
.
filter
(
Boolean
)
.
slice
(
0
,
MAX_TAGS_LIMIT
)
;
for
(
let
tag
of
allTags
)
{
const
res
=
repo
.
filter
(
tag
)
;
if
(
res
!==
null
)
{
return
res
;
}
}
return
{
version
:
null
,
tag
:
null
}
;
}
catch
(
err
)
{
console
.
error
(
err
.
stack
)
;
process
.
exit
(
1
)
;
}
}
async
function
main
(
)
{
if
(
process
.
argv
[
2
]
===
"tag"
)
{
const
{
tag
}
=
await
latest
(
src
)
;
console
.
log
(
tag
)
;
return
;
}
let
{
version
:
srcVer
}
=
await
latest
(
src
)
;
let
{
version
:
dstVer
}
=
await
latest
(
dst
)
;
if
(
!
dstVer
||
isGreater
(
srcVer
,
dstVer
)
)
{
console
.
log
(
srcVer
)
;
}
else
{
console
.
log
(
`
${
srcVer
}
-nightly.
${
dateFormat
(
Date
.
UTC
(
)
,
"yyyymmdd"
)
}
`
)
;
}
}
main
(
)
;
Back
|
FazBrowse Home
|
New Git URL