Skip to content

Commit c28abca

Browse files
committed
Add solc.semver() method to get a consistent version number in all cases
1 parent e7879af commit c28abca

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ The `compile()` method always returns an object, which can contain `errors`, `so
8989

9090
Starting from version 0.4.11 there is a new entry point named `compileStandardWrapper()` which supports Solidity's [standard JSON input and output](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description). It also maps old compiler output to it.
9191

92+
#### From version 0.4.20
93+
94+
Starting from version 0.4.20 a Semver compatible version number can be retrieved on every compiler release, including old ones, using the `semver()` method.
95+
9296
### Using with Electron
9397

9498
**Note:**

test/package.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ tape('Version and license', function (t) {
66
st.equal(typeof solc.version(), 'string');
77
st.end();
88
});
9+
t.test('check semver', function (st) {
10+
st.equal(typeof solc.semver(), 'string');
11+
st.end();
12+
});
913
t.test('check license', function (st) {
1014
st.ok(typeof solc.license() === 'undefined' || typeof solc.license() === 'string');
1115
st.end();

wrapper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ function setupMethods (soljson) {
157157

158158
var version = soljson.cwrap('version', 'string', []);
159159

160+
var versionToSemver = function () {
161+
return translate.versionToSemver(version());
162+
};
163+
160164
var license = function () {
161165
// return undefined
162166
};
@@ -167,6 +171,7 @@ function setupMethods (soljson) {
167171

168172
return {
169173
version: version,
174+
semver: versionToSemver,
170175
license: license,
171176
compile: compile,
172177
compileStandard: compileStandard,

0 commit comments

Comments
 (0)