@@ -11,24 +11,27 @@ const swarmhash = require('swarmhash')
11
11
// This script updates the index files list.js and list.txt in the directories containing binaries,
12
12
// as well as the 'latest' and 'nightly' symlinks/files.
13
13
14
- function updateSymlink ( linkPathRelativeToRoot , targetRelativeToLink ) {
14
+ function updateSymlinkSync ( linkPathRelativeToRoot , targetRelativeToLink ) {
15
15
const absoluteLinkPath = path . join ( __dirname , linkPathRelativeToRoot )
16
+ let linkString
16
17
17
- fs . readlink ( absoluteLinkPath , ( err , linkString ) => {
18
- if ( err && err . code !== 'ENOENT' ) {
19
- throw err
20
- }
18
+ try {
19
+ linkString = fs . readlinkSync ( absoluteLinkPath )
21
20
22
- if ( ! err && targetRelativeToLink !== linkString ) {
21
+ if ( targetRelativeToLink !== linkString ) {
23
22
fs . unlinkSync ( absoluteLinkPath )
24
23
console . log ( 'Removed link ' + linkPathRelativeToRoot + ' -> ' + linkString )
25
24
}
26
-
27
- if ( err || targetRelativeToLink !== linkString ) {
28
- fs . symlinkSync ( targetRelativeToLink , absoluteLinkPath , 'file' )
29
- console . log ( 'Created link ' + linkPathRelativeToRoot + ' -> ' + targetRelativeToLink )
25
+ } catch ( err ) {
26
+ if ( err . code !== 'ENOENT' ) {
27
+ throw err
30
28
}
31
- } )
29
+ }
30
+
31
+ if ( targetRelativeToLink !== linkString ) {
32
+ fs . symlinkSync ( targetRelativeToLink , absoluteLinkPath , 'file' )
33
+ console . log ( 'Created link ' + linkPathRelativeToRoot + ' -> ' + targetRelativeToLink )
34
+ }
32
35
}
33
36
34
37
function updateCopy ( srcRelativeToRoot , destRelativeToRoot ) {
@@ -192,12 +195,12 @@ function processDir (dir, listCallback) {
192
195
if ( dir === '/bin' ) {
193
196
updateCopy ( path . join ( dir , latestReleaseFile ) , path . join ( dir , binaryPrefix + '-latest' + binaryExtension ) )
194
197
} else if ( dir !== '/wasm' ) {
195
- updateSymlink ( path . join ( dir , binaryPrefix + '-latest' + binaryExtension ) , latestReleaseFile )
198
+ updateSymlinkSync ( path . join ( dir , binaryPrefix + '-latest' + binaryExtension ) , latestReleaseFile )
196
199
}
197
200
198
201
// Update 'nightly' symlink in bin/ (we don't have nightlies for other platforms)
199
202
if ( dir === '/bin' ) {
200
- updateSymlink ( path . join ( dir , binaryPrefix + '-nightly' + binaryExtension ) , latestBuildFile )
203
+ updateSymlinkSync ( path . join ( dir , binaryPrefix + '-nightly' + binaryExtension ) , latestBuildFile )
201
204
}
202
205
} )
203
206
}
@@ -221,7 +224,7 @@ DIRS.forEach(function (dir) {
221
224
// We don't need to do this for emscripten-asmjs/ because we don't build asm.js releases any more.
222
225
parsedList . forEach ( function ( release ) {
223
226
if ( release . prerelease === undefined ) {
224
- updateSymlink (
227
+ updateSymlinkSync (
225
228
path . join ( '/emscripten-wasm32' , 'solc-emscripten-wasm32-v' + release . longVersion + '.js' ) ,
226
229
path . join ( '..' , 'wasm' , release . path )
227
230
)
0 commit comments