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 13, 2020
1 parent db12694 commit c4d99f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 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
41 changes: 17 additions & 24 deletions update
Original file line number Diff line number Diff line change
Expand Up @@ -111,36 +111,29 @@ 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')
})
})
const linksAndTargets = {
[path.join(dir, '/soljson-latest.js')]: latestReleaseFile,
[path.join(dir, '/soljson-nightly.js')]: latestBuildFile
}

// Read latest build file
fs.readFile(path.join(__dirname, dir, latestBuildFile), function (err, data) {
if (err) {
throw err
}
for (const link in linksAndTargets) {
const absoluteLink = path.join(__dirname, link)

// Copy to bin/soljson-nightly.js
fs.writeFile(path.join(__dirname, dir, '/soljson-nightly.js'), data, function (err) {
fs.lstat(absoluteLink, (err, stats) => {
if (err) {
throw err
if (err.code !== 'ENOENT')
throw err
}
console.log('Updated ' + dir + '/soljson-nightly.js')
else
// It exists. Assume it's a symbolic link. unlinkSync() will fail otherwise anyway.
fs.unlinkSync(absoluteLink)

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

0 comments on commit c4d99f1

Please sign in to comment.