11const linker = require ( './linker.js' ) ;
22
33/// Translate old style version numbers to semver.
4- /// Old style: 0.3.6-3fc68da5/Release-Emscripten/clang
4+ /// Old style: 0.4.1-nightly.2016.09.09+commit.79867f49.Emscripten.clang
5+ /// 0.3.6-nightly.2016.08.27+commit.91d4fa47.Emscripten.clang
6+ /// 0.3.6-3fc68da5/Release-Emscripten/clang
57/// 0.3.5-371690f0/Release-Emscripten/clang/Interpreter
68/// 0.3.5-0/Release-Emscripten/clang/Interpreter
9+ /// 0.3.4-0/Release-Emscripten/clang/Interpreter
710/// 0.2.0-e7098958/.-Emscripten/clang/int linked to libethereum-1.1.1-bbb80ab0/.-Emscripten/clang/int
811/// 0.1.3-0/.-/clang/int linked to libethereum-0.9.92-0/.-/clang/int
912/// 0.1.2-5c3bfd4b*/.-/clang/int
1013/// 0.1.1-6ff4cd6b/RelWithDebInfo-Emscripten/clang/int
11- /// New style: 0.4.5+commit.b318366e.Emscripten.clang
14+ /// New style: 0.8.1-nightly.2021.1.7+commit.d11cf15d.js
15+ /// 0.4.5+commit.b318366e.Emscripten.clang
1216function versionToSemver ( version ) {
17+ // This parses the old style with a commit hash. It ignores the details past the commit hash.
1318 // FIXME: parse more detail, but this is a good start
1419 const parsed = version . match ( / ^ ( [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + ) - ( [ 0 - 9 a - f ] { 8 } ) [ / * ] .* $ / ) ;
1520 if ( parsed ) {
@@ -18,9 +23,17 @@ function versionToSemver (version) {
1823 if ( version . indexOf ( '0.1.3-0' ) !== - 1 ) {
1924 return '0.1.3' ;
2025 }
26+ if ( version . indexOf ( '0.3.4-0' ) !== - 1 ) {
27+ return '0.3.4-nightly' ;
28+ }
2129 if ( version . indexOf ( '0.3.5-0' ) !== - 1 ) {
2230 return '0.3.5' ;
2331 }
32+ // This parses the obsolete nightly style where the date can have leading zeroes.
33+ const nightlyParsed = version . match ( / ^ ( [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + ) - n i g h t l y \. ( [ 0 - 9 ] + ) \. 0 ? ( [ 1 - 9 ] ) \. 0 ? ( [ 1 - 9 ] ) ( .* ) $ / ) ;
34+ if ( nightlyParsed ) {
35+ return nightlyParsed [ 1 ] + '-nightly.' + nightlyParsed [ 2 ] + '.' + nightlyParsed [ 3 ] + '.' + nightlyParsed [ 4 ] + nightlyParsed [ 5 ] ;
36+ }
2437 // assume it is already semver compatible
2538 return version ;
2639}
0 commit comments