Skip to content

Commit 46fac73

Browse files
authored
Merge pull request #8 from ethereum/sort
Sort using semver
2 parents e110c90 + 048c160 commit 46fac73

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# node-waf configuration
20+
.lock-wscript
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27+
node_modules

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
language: node_js
2+
script: npm run lint && npm run test

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"private": true,
3+
"name": "solc-bin",
4+
"version": "0.0.0",
5+
"description": "Current and historical (emscripten) binaries for Solidity",
6+
"dependencies": {
7+
"semver": "^5.3.0"
8+
},
9+
"devDependencies": {
10+
"standard": "^8.4.0"
11+
},
12+
"scripts": {
13+
"lint": "standard update",
14+
"update": "./update",
15+
"test": "git checkout -f && npm run update && git diff"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "git+https://github.com/ethereum/solc-bin.git"
20+
},
21+
"keywords": [
22+
"ethereum",
23+
"solidity"
24+
],
25+
"author": "",
26+
"license": "GPL-3.0",
27+
"bugs": {
28+
"url": "https://github.com/ethereum/solc-bin/issues"
29+
},
30+
"homepage": "https://github.com/ethereum/solc-bin#readme"
31+
}

update

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
const fs = require('fs')
66
const path = require('path')
7+
const semver = require('semver')
78

89
// This script updates the index files list.js and list.txt in the bin directory,
910
// as well as the soljson-latest.js files.
@@ -13,10 +14,26 @@ fs.readdir(path.join(__dirname, '/bin'), function (err, files) {
1314
throw err
1415
}
1516

17+
function buildVersion (build) {
18+
var version = build.version
19+
if (build.prerelease && build.prerelease.length > 0) {
20+
version += '-' + build.prerelease
21+
}
22+
if (build.build && build.build.length > 0) {
23+
version += '+' + build.build
24+
}
25+
return version
26+
}
27+
28+
// ascending list (oldest version first)
1629
const parsedList = files
1730
.map(function (file) { return file.match(/^soljson-v([0-9.]*)(-([^+]*))?(\+(.*))?.js$/) })
1831
.filter(function (version) { return version })
1932
.map(function (pars) { return { path: pars[0], version: pars[1], prerelease: pars[3], build: pars[5] } })
33+
.sort(function (a, b) {
34+
// NOTE: a vs. b (the order is important), because we want oldest first in the list
35+
return semver.compare(buildVersion(a), buildVersion(b))
36+
})
2037

2138
// descending list
2239
const releases = parsedList

0 commit comments

Comments
 (0)