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

Replace latest and nightly copies in bin/ with symlinks #33

Merged
merged 2 commits into from
Jul 17, 2020
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
1 change: 0 additions & 1 deletion bin/soljson-latest.js

This file was deleted.

1 change: 1 addition & 0 deletions bin/soljson-latest.js
1 change: 0 additions & 1 deletion bin/soljson-nightly.js

This file was deleted.

1 change: 1 addition & 0 deletions bin/soljson-nightly.js
56 changes: 25 additions & 31 deletions update
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,28 @@ const semver = require('semver')
const ethUtil = require('ethereumjs-util')
const swarmhash = require('swarmhash')

// This script updates the index files list.js and list.txt in the bin directory,
// as well as the soljson-latest.js files.
// This script updates the index files list.js and list.txt in the directories containing binaries,
// as well as the 'latest' and 'nightly' symlinks.

function updateSymlink (linkPathRelativeToRoot, targetRelativeToLink) {
const absoluteLinkPath = path.join(__dirname, linkPathRelativeToRoot)

fs.readlink(absoluteLinkPath, (err, linkString) => {
if (err && err.code !== 'ENOENT') {
throw err
}

if (!err && targetRelativeToLink !== linkString) {
fs.unlinkSync(absoluteLinkPath)
console.log('Removed link ' + linkPathRelativeToRoot + ' -> ' + linkString)
}

if (err || targetRelativeToLink !== linkString) {
fs.symlinkSync(targetRelativeToLink, absoluteLinkPath, 'file')
console.log('Created link ' + linkPathRelativeToRoot + ' -> ' + targetRelativeToLink)
}
})
}

var dirs = ['/bin', '/wasm']
dirs.forEach(function (dir) {
Expand Down Expand Up @@ -117,36 +137,10 @@ dirs.forEach(function (dir) {
console.log('Updated ' + dir + '/list.js')
})

// Update symlinks
if (dir === '/bin') {
// Read latest release file
fs.readFile(path.join(__dirname, dir, latestReleaseFile), function (err, data) {
if (err) {
throw err
}

// Copy to bin/soljson-latest.js
fs.writeFile(path.join(__dirname, dir, '/soljson-latest.js'), data, function (err) {
if (err) {
throw err
}
console.log('Updated ' + dir + '/soljson-latest.js')
})
})

// Read latest build file
fs.readFile(path.join(__dirname, dir, latestBuildFile), function (err, data) {
if (err) {
throw err
}

// Copy to bin/soljson-nightly.js
fs.writeFile(path.join(__dirname, dir, '/soljson-nightly.js'), data, function (err) {
if (err) {
throw err
}
console.log('Updated ' + dir + '/soljson-nightly.js')
})
})
updateSymlink(path.join(dir, 'soljson-latest.js'), latestReleaseFile)
updateSymlink(path.join(dir, 'soljson-nightly.js'), latestBuildFile)
}
})
})
Expand Down