-
Notifications
You must be signed in to change notification settings - Fork 49
/
install-npm.js
53 lines (48 loc) · 1.56 KB
/
install-npm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
var fs = require('fs')
, path = require('path');
function waitForDeps (cb) {
// see if we can import the necessary code
// try it a ridiculous (but finite) number of times
var i = 0;
function check () {
i++;
try {
require('./build/lib/installer');
cb();
} catch (err) {
if (err.message.indexOf("Cannot find module './build/lib/installer'") !== -1) {
console.warn('Project does not appear to built yet. Please run `gulp transpile` first.');
return cb('Could not install module: ' + err);
}
console.warn('Error trying to install WinAppDriver MSI. Waiting and trying again.', err.message);
if (i <= 200) {
setTimeout(check, 1000);
} else {
cb('Could not import installation module: ' + err);
}
}
}
check();
}
if (require.main === module) {
// check if cur dir exists
var installScript = path.resolve(__dirname, 'build', 'lib', 'installer.js');
waitForDeps(function (err) {
if (err) {
console.warn("Unable to import install script. Re-run `install appium-windows-driver` manually.");
return;
}
fs.stat(installScript, function (err) {
if (err) {
console.warn("NOTE: Run 'gulp transpile' before using");
return;
}
require('./build/lib/installer').setupWAD().catch(function (err) {
console.error(err.message);
console.error("WinAppDriver was not installed; please check your " +
"system and re-run npm install if you need WinAppDriver");
});
});
});
}