Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use symlink for bin/soljson-latest.js #156

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions bin/soljson-latest.js

This file was deleted.

1 change: 1 addition & 0 deletions bin/soljson-latest.js
36 changes: 1 addition & 35 deletions update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
readFileSync,
writeFile,
readdir,
stat,
lstat
} from 'fs'

Expand Down Expand Up @@ -70,33 +69,6 @@ function updateSymlinkSync (linkPathRelativeToRoot, targetRelativeToLink) {
}
}

function updateCopy (srcRelativeToRoot, destRelativeToRoot) {
readFileSync(join(__dirname, srcRelativeToRoot), function (err, data) {
if (err) {
throw err
}

const absoluteDest = join(__dirname, destRelativeToRoot)
stat(absoluteDest, function (err, stats) {
if (err && err.code !== 'ENOENT') {
throw err
}

// If the target is a symlink, we want to replace it with a copy rather than overwrite the file it links to
if (!err && stats.isSymbolicLink()) {
unlinkSync(absoluteDest)
}

writeFile(absoluteDest, data, function (err) {
if (err) {
throw err
}
console.log('Updated ' + destRelativeToRoot)
})
})
})
}

function deleteIfExists (filePathRelativeToRoot) {
const absoluteFilePath = join(__dirname, filePathRelativeToRoot)

Expand Down Expand Up @@ -301,8 +273,6 @@ function processDir (dir, options, listCallback) {
})

// Update 'latest' symlink (except for wasm/ where the link is hard-coded to point at the one in bin/).
// bin/ is a special case because we need to keep a copy rather than a symlink. The reason is that
// some tools (in particular solc-js) have hard-coded github download URLs to it and can't handle symlinks.
if (dir !== '/wasm') {
const releaseExtension = binaryExtensions.find(function (extension) { return latestReleaseFile.endsWith(extension) })

Expand All @@ -312,11 +282,7 @@ function processDir (dir, options, listCallback) {
}
})

if (dir === '/bin') {
updateCopy(join(dir, latestReleaseFile), join(dir, binaryPrefix + '-latest' + releaseExtension))
} else {
updateSymlinkSync(join(dir, binaryPrefix + '-latest' + releaseExtension), latestReleaseFile)
}
updateSymlinkSync(join(dir, binaryPrefix + '-latest' + releaseExtension), latestReleaseFile)
}

// Update 'nightly' symlink in bin/ (we don't have nightlies for other platforms)
Expand Down
Loading