ios-simulator
Advanced tools
Comparing version 1.0.7 to 1.0.9
13
index.js
@@ -1,16 +0,3 @@ | ||
/* ================================================================ | ||
* ios-simulator by xdf(xudafeng[at]126.com) | ||
* | ||
* first created at : Thu Feb 18 2016 21:24:24 GMT+0800 (CST) | ||
* | ||
* ================================================================ | ||
* Copyright xdf | ||
* | ||
* Licensed under the MIT License | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* ================================================================ */ | ||
'use strict'; | ||
module.exports = require('./lib/ios-simulator'); |
@@ -1,14 +0,1 @@ | ||
/* ================================================================ | ||
* ios-simulator by xdf(xudafeng[at]126.com) | ||
* | ||
* first created at : Thu Aug 06 2015 14:48:08 GMT+0800 (CST) | ||
* | ||
* ================================================================ | ||
* Copyright xdf | ||
* | ||
* Licensed under the MIT License | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* ================================================================ */ | ||
'use strict'; | ||
@@ -15,0 +2,0 @@ |
@@ -1,14 +0,1 @@ | ||
/* ================================================================ | ||
* ios-simulator by xdf(xudafeng[at]126.com) | ||
* | ||
* first created at : Thu Feb 18 2016 21:24:24 GMT+0800 (CST) | ||
* | ||
* ================================================================ | ||
* Copyright xdf | ||
* | ||
* Licensed under the MIT License | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* ================================================================ */ | ||
'use strict'; | ||
@@ -150,5 +137,8 @@ | ||
Simulator.prototype.exists = function(bundleId) { | ||
return this | ||
.listInstalledApps() | ||
.then(bundleIds => !!~bundleIds.indexOf(bundleId)); | ||
var cmd = `xcrun simctl get_app_container ${this.deviceId} ${bundleId}`; | ||
return _.exec(cmd).then(_ => { | ||
return true; | ||
}).catch(_ => { | ||
return false; | ||
}); | ||
}; | ||
@@ -155,0 +145,0 @@ |
@@ -1,14 +0,1 @@ | ||
/* ================================================================ | ||
* ios-simulator by xdf(xudafeng[at]126.com) | ||
* | ||
* first created at : Thu Aug 06 2015 14:48:08 GMT+0800 (CST) | ||
* | ||
* ================================================================ | ||
* Copyright xdf | ||
* | ||
* Licensed under the MIT License | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* ================================================================ */ | ||
'use strict'; | ||
@@ -15,0 +2,0 @@ |
{ | ||
"name": "ios-simulator", | ||
"version": "1.0.7", | ||
"description": "ios-simulator", | ||
"version": "1.0.9", | ||
"description": "iOS Simulator Node.js wrapper", | ||
"keywords": [ | ||
@@ -11,3 +11,3 @@ "ios-simulator" | ||
"type": "git", | ||
"url": "git://github.com/xudafeng/ios-simulator.git" | ||
"url": "git://github.com/macacajs/ios-simulator.git" | ||
}, | ||
@@ -34,7 +34,4 @@ "dependencies": { | ||
], | ||
"homepage": "https://github.com/xudafeng/ios-simulator", | ||
"author": "xudafeng", | ||
"email": "xudafeng@126.com", | ||
"blog": "http://xdf.me", | ||
"homepage": "https://github.com/macacajs/ios-simulator", | ||
"license": "MIT" | ||
} |
@@ -11,6 +11,6 @@ # ios-simulator | ||
[npm-url]: https://npmjs.org/package/ios-simulator | ||
[travis-image]: https://img.shields.io/travis/xudafeng/ios-simulator.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/xudafeng/ios-simulator | ||
[coveralls-image]: https://img.shields.io/coveralls/xudafeng/ios-simulator.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/xudafeng/ios-simulator?branch=master | ||
[travis-image]: https://img.shields.io/travis/macacajs/ios-simulator.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/macacajs/ios-simulator | ||
[coveralls-image]: https://img.shields.io/coveralls/macacajs/ios-simulator.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/macacajs/ios-simulator?branch=master | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square | ||
@@ -21,3 +21,3 @@ [node-url]: http://nodejs.org/download/ | ||
> ios simulator | ||
> iOS Simulator Node.js wrapper | ||
@@ -41,3 +41,1 @@ ## Installment | ||
The MIT License (MIT) | ||
Copyright (c) 2015 xdf |
@@ -1,14 +0,1 @@ | ||
/* ================================================================ | ||
* ios-simulator by xdf(xudafeng[at]126.com) | ||
* | ||
* first created at : Thu Feb 18 2016 21:24:24 GMT+0800 (CST) | ||
* | ||
* ================================================================ | ||
* Copyright xdf | ||
* | ||
* Licensed under the MIT License | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* ================================================================ */ | ||
'use strict'; | ||
@@ -18,8 +5,55 @@ | ||
var sim = null; | ||
var resetEnv = function *() { | ||
try { | ||
yield Simulator.killAll(); | ||
} catch (e) { | ||
console.log(e.stack); | ||
} | ||
}; | ||
var getSim = function *() { | ||
var devices = yield Simulator.getDevices(); | ||
var matchedDevice = null; | ||
devices.forEach(function(device) { | ||
if (device.name === 'iPhone 5s' && device.available) { | ||
matchedDevice = device; | ||
} | ||
}); | ||
if (matchedDevice.state === 'Booted') { | ||
try { | ||
sim = new Simulator(); | ||
sim.setDeviceId(matchedDevice.udid); | ||
yield sim.shutdown(); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
if (matchedDevice) { | ||
sim = new Simulator(); | ||
sim.setDeviceId(matchedDevice.udid); | ||
} else { | ||
sim = null; | ||
} | ||
}; | ||
describe('lib/ios-simulator.js', function() { | ||
it('should be', function() { | ||
beforeEach(function *() { | ||
yield getSim(); | ||
}); | ||
afterEach(function *() { | ||
yield resetEnv(); | ||
}); | ||
it('should be ok', function() { | ||
Simulator.should.be.ok; | ||
}); | ||
it('getDevices callback', function(done) { | ||
it('getDevices callback', function *(done) { | ||
Simulator.getDevices(function(err, data) { | ||
@@ -47,26 +81,11 @@ if (err) { | ||
it('boot callback', function *(done) { | ||
try { | ||
yield Simulator.killAll(); | ||
} catch(e) { | ||
console.log(e.stack); | ||
} | ||
var devices = yield Simulator.getDevices(); | ||
devices.forEach(function(device) { | ||
if (device.name === 'iPhone 5s') { | ||
if (device.state === 'Booted') { | ||
done(); | ||
return; | ||
} | ||
var sim = new Simulator(); | ||
sim.setDeviceId(device.udid); | ||
sim.boot(function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
return; | ||
} | ||
console.log(data); | ||
done(); | ||
}); | ||
sim.boot(function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
return; | ||
} | ||
console.log(data); | ||
done(); | ||
}); | ||
@@ -76,93 +95,49 @@ }); | ||
it('boot promise', function *(done) { | ||
try { | ||
yield Simulator.killAll(); | ||
} catch(e) { | ||
console.log(e.stack); | ||
} | ||
var devices = yield Simulator.getDevices(); | ||
devices.forEach(function(device) { | ||
if (device.name === 'iPhone 5s') { | ||
if (device.state === 'Booted') { | ||
done(); | ||
return; | ||
} | ||
var sim = new Simulator(); | ||
sim.setDeviceId(device.udid); | ||
sim.boot().then(function(data) { | ||
console.log(data); | ||
done(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
done(); | ||
}); | ||
} | ||
sim.boot().then(function(data) { | ||
console.log(data); | ||
done(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
done(); | ||
}); | ||
}); | ||
it('shutdown callback', function *(done) { | ||
var devices = yield Simulator.getDevices(); | ||
devices.forEach(function(device) { | ||
if (device.name === 'iPhone 5s') { | ||
if (device.state !== 'Booted') { | ||
done(); | ||
return; | ||
} | ||
var sim = new Simulator(); | ||
sim.setDeviceId(device.udid); | ||
sim.shutdown(function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
return; | ||
} | ||
console.log(data); | ||
done(); | ||
}); | ||
sim.shutdown(function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
return; | ||
} | ||
console.log(data); | ||
done(); | ||
}); | ||
}); | ||
it('shutdown promise', function *(done) { | ||
var devices = yield Simulator.getDevices(); | ||
devices.forEach(function(device) { | ||
if (device.name === 'iPhone 5s') { | ||
if (device.state !== 'Booted') { | ||
done(); | ||
return; | ||
} | ||
var sim = new Simulator(); | ||
sim.setDeviceId(device.udid); | ||
sim.shutdown().then(function(data) { | ||
console.log(data); | ||
done(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
done(); | ||
}); | ||
} | ||
sim.shutdown().then(function(data) { | ||
console.log(data); | ||
done(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
done(); | ||
}); | ||
}); | ||
it('open callback', function *(done) { | ||
try { | ||
yield Simulator.killAll(); | ||
} catch(e) { | ||
console.log(e.stack); | ||
} | ||
var devices = yield Simulator.getDevices(); | ||
devices.forEach(function(device) { | ||
if (device.name === 'iPhone 5s') { | ||
var sim = new Simulator(); | ||
sim.setDeviceId(device.udid); | ||
sim.open(function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
return; | ||
} | ||
console.log(data); | ||
done(); | ||
}); | ||
sim.open(function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
done(); | ||
return; | ||
} | ||
console.log(data); | ||
done(); | ||
}); | ||
@@ -172,21 +147,10 @@ }); | ||
it('open promise', function *(done) { | ||
try { | ||
yield Simulator.killAll(); | ||
} catch(e) { | ||
console.log(e.stack); | ||
} | ||
var devices = yield Simulator.getDevices(); | ||
devices.forEach(function(device) { | ||
if (device.name === 'iPhone 5s') { | ||
var sim = new Simulator(); | ||
sim.setDeviceId(device.udid); | ||
sim.open().then(function(data) { | ||
done(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
done(); | ||
}); | ||
} | ||
sim.open().then(function(data) { | ||
done(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
14290
402
1
39