Skip to content

Commit

Permalink
feat: add support to node-webkit target. (#34)
Browse files Browse the repository at this point in the history
* Adding support to node-webkit target.

* Adding tests for target sorting.

* move node-webkit to additionalTargets + export additionalTargets

* document additionalTargets
  • Loading branch information
saboya authored and lgeiger committed Jan 28, 2018
1 parent 47eca66 commit 1e324fb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ nodeAbi.allTargets
// ]
nodeAbi.deprecatedTargets
nodeAbi.supportedTargets
nodeAbi.additionalTargets
nodeAbi.futureTargets
// ...
```
Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ var supportedTargets = [
{runtime: 'electron', target: '1.8.0', abi: '57', lts: false}
]

var additionalTargets = [
{runtime: 'node-webkit', target: '0.13.0', abi: '47', lts: false},
{runtime: 'node-webkit', target: '0.15.0', abi: '48', lts: false},
{runtime: 'node-webkit', target: '0.18.3', abi: '51', lts: false},
{runtime: 'node-webkit', target: '0.23.0', abi: '57', lts: false},
{runtime: 'node-webkit', target: '0.26.5', abi: '59', lts: false}
]

var deprecatedTargets = [
{runtime: 'node', target: '0.2.0', abi: '1', lts: false},
{runtime: 'node', target: '0.9.1', abi: '0x000A', lts: false},
Expand All @@ -84,12 +92,16 @@ var deprecatedTargets = [

var futureTargets = []

var allTargets = deprecatedTargets.concat(supportedTargets).concat(futureTargets)
var allTargets = deprecatedTargets
.concat(supportedTargets)
.concat(additionalTargets)
.concat(futureTargets)

exports.getAbi = getAbi
exports.getTarget = getTarget
exports.deprecatedTargets = deprecatedTargets
exports.supportedTargets = supportedTargets
exports.additionalTargets = additionalTargets
exports.futureTargets = futureTargets
exports.allTargets = allTargets
exports._getNextTarget = getNextTarget
34 changes: 34 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ test('getTarget calculates correct Electron target', function (t) {
t.end()
})

test('getTarget calculates correct Node-Webkit target', function (t) {
t.throws(getTarget.bind(null, '14', 'ode-webkit'))
t.equal(getTarget('47', 'node-webkit'), '0.13.0')
t.equal(getTarget('48', 'node-webkit'), '0.15.0')
t.equal(getTarget('51', 'node-webkit'), '0.18.3')
t.equal(getTarget('57', 'node-webkit'), '0.23.0')
t.equal(getTarget('59', 'node-webkit'), '0.26.5')
t.end()
})

test('getAbi calculates correct Node ABI', function (t) {
t.equal(getAbi(undefined), process.versions.modules)
t.equal(getAbi(null), process.versions.modules)
Expand Down Expand Up @@ -94,6 +104,28 @@ test('getAbi calculates correct Electron ABI', function (t) {
t.end()
})

test('getAbi calculates correct Node-Webkit ABI', function (t) {
t.throws(function () { getAbi(undefined, 'node-webkit') })
t.throws(function () { getAbi(getNextTarget('node-webkit'), 'node-webkit') })
t.equal(getAbi('0.13.0', 'node-webkit'), '47')
t.equal(getAbi('0.14.0', 'node-webkit'), '47')
t.equal(getAbi('0.15.0', 'node-webkit'), '48')
t.equal(getAbi('0.16.0', 'node-webkit'), '48')
t.equal(getAbi('0.17.0', 'node-webkit'), '48')
t.equal(getAbi('0.18.2', 'node-webkit'), '48')
t.equal(getAbi('0.18.3', 'node-webkit'), '51')
t.equal(getAbi('0.19.0', 'node-webkit'), '51')
t.equal(getAbi('0.20.0', 'node-webkit'), '51')
t.equal(getAbi('0.21.0', 'node-webkit'), '51')
t.equal(getAbi('0.22.0', 'node-webkit'), '51')
t.equal(getAbi('0.23.0', 'node-webkit'), '57')
t.equal(getAbi('0.24.0', 'node-webkit'), '57')
t.equal(getAbi('0.25.0', 'node-webkit'), '57')
t.equal(getAbi('0.26.4', 'node-webkit'), '57')
t.equal(getAbi('0.26.5', 'node-webkit'), '59')
t.end()
})

test('getAbi supports leading v', function (t) {
t.equal(getAbi('v7.2.0'), '51')
t.end()
Expand All @@ -107,11 +139,13 @@ test('getAbi returns abi if passed as target', function (t) {
test('allTargets are sorted', function (t) {
var electron = allTargets.filter(function (t) { return t.runtime === 'electron' })
var node = allTargets.filter(function (t) { return t.runtime === 'node' })
var nodeWebkit = allTargets.filter(function (t) { return t.runtime === 'node-webkit' })
function sort (t1, t2) {
return semver.compare(t1.target, t2.target)
}

t.deepEqual(electron, electron.slice().sort(sort))
t.deepEqual(node, node.slice().sort(sort))
t.deepEqual(nodeWebkit, nodeWebkit.slice().sort(sort))
t.end()
})

0 comments on commit 1e324fb

Please sign in to comment.