Skip to content

Commit

Permalink
update script: Use symlinks rather than copies for 'latest' and 'nigh…
Browse files Browse the repository at this point in the history
…tly'
  • Loading branch information
cameel committed Jul 16, 2020
1 parent 5158d09 commit f30c903
Showing 1 changed file with 25 additions and 31 deletions.
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

0 comments on commit f30c903

Please sign in to comment.