Skip to content

Commit

Permalink
Replace latest and nightly copies in bin/ with symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Jul 7, 2020
1 parent 16d460b commit e8fe2fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 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
38 changes: 16 additions & 22 deletions update
Original file line number Diff line number Diff line change
Expand Up @@ -111,36 +111,30 @@ 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
}
const linksAndTargets = {
[path.join(dir, '/soljson-latest.js')]: latestReleaseFile,
[path.join(dir, '/soljson-nightly.js')]: latestBuildFile
}

for (const link in linksAndTargets) {
const absoluteLink = path.join(__dirname, link)

// Copy to bin/soljson-latest.js
fs.writeFile(path.join(__dirname, dir, '/soljson-latest.js'), data, function (err) {
fs.lstat(absoluteLink, (err, stats) => {
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
if (stats) {
// It exists. Assume it's a symbolic link. unlinkSync() will fail otherwise anyway.
fs.unlinkSync(absoluteLink)
}
console.log('Updated ' + dir + '/soljson-nightly.js')

fs.symlinkSync(linksAndTargets[link], absoluteLink, 'file')
console.log('Updated ' + link + ' to point at ' + linksAndTargets[link])
})
})
}
}
})
})
Expand Down

0 comments on commit e8fe2fc

Please sign in to comment.