Skip to content

Commit

Permalink
Merge pull request #33 from ethereum/replace-latest-and-nightly-with-…
Browse files Browse the repository at this point in the history
…symlinks

Replace latest and nightly copies in bin/ with symlinks
  • Loading branch information
chriseth committed Jul 17, 2020
2 parents faf85e9 + 2d4517c commit ec4a845
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
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

0 comments on commit ec4a845

Please sign in to comment.