mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-20 15:20:23 -05:00
launcher: ignore generated js files, close #5
This commit is contained in:
@@ -31,4 +31,8 @@ node_modules
|
||||
.npm
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
.node_repl_history
|
||||
|
||||
# JS files generated from TypeScript files
|
||||
lib/*.js
|
||||
lib/**/*.js
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var log_1 = require("./log");
|
||||
var lodash_1 = require("lodash");
|
||||
var cp = require("child_process");
|
||||
var browserNotFoundErr = function (browsers, name) {
|
||||
var available = lodash_1.map(browsers, 'name').join(', ');
|
||||
var err = new Error("Browser: '" + name + "' not found. Available browsers are: [" + available + "]");
|
||||
err.specificBrowserNotFound = true;
|
||||
return err;
|
||||
};
|
||||
/** starts a browser by name and opens URL if given one */
|
||||
function launch(browsers, name, url, args) {
|
||||
if (args === void 0) { args = []; }
|
||||
log_1.log('launching browser %s to open %s', name, url);
|
||||
var browser = lodash_1.find(browsers, { name: name });
|
||||
if (!browser) {
|
||||
throw browserNotFoundErr(browsers, name);
|
||||
}
|
||||
if (url) {
|
||||
args.unshift(url);
|
||||
}
|
||||
return cp.spawn(browser.path, args, { stdio: 'ignore' });
|
||||
}
|
||||
exports.launch = launch;
|
||||
@@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var util_1 = require("./util");
|
||||
var path = require("path");
|
||||
var Promise = require("bluebird");
|
||||
var canary = {
|
||||
version: function (p) {
|
||||
return util_1.parse(p, 'KSVersion');
|
||||
},
|
||||
path: function () { return util_1.find('com.google.Chrome.canary'); },
|
||||
get: function (executable) {
|
||||
var _this = this;
|
||||
return this.path()
|
||||
.then(function (p) {
|
||||
return Promise.props({
|
||||
path: path.join(p, executable),
|
||||
version: _this.version(p)
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = canary;
|
||||
@@ -1,26 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var log_1 = require("../log");
|
||||
var util_1 = require("./util");
|
||||
var path = require("path");
|
||||
var Promise = require("bluebird");
|
||||
var chrome = {
|
||||
version: function (p) {
|
||||
return util_1.parse(p, 'KSVersion');
|
||||
},
|
||||
path: function () {
|
||||
return util_1.find('com.google.Chrome');
|
||||
},
|
||||
get: function (executable) {
|
||||
var _this = this;
|
||||
log_1.log('Looking for Chrome %s', executable);
|
||||
return this.path()
|
||||
.then(function (p) {
|
||||
return Promise.props({
|
||||
path: path.join(p, executable),
|
||||
version: _this.version(p)
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = chrome;
|
||||
@@ -1,24 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var util_1 = require("./util");
|
||||
var path = require("path");
|
||||
var Promise = require("bluebird");
|
||||
var chromium = {
|
||||
version: function (p) {
|
||||
return util_1.parse(p, 'CFBundleShortVersionString');
|
||||
},
|
||||
path: function () {
|
||||
return util_1.find('org.chromium.Chromium');
|
||||
},
|
||||
get: function (executable) {
|
||||
var _this = this;
|
||||
return this.path()
|
||||
.then(function (p) {
|
||||
return Promise.props({
|
||||
path: path.join(p, executable),
|
||||
version: _this.version(p)
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.default = chromium;
|
||||
@@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var canary_1 = require("./canary");
|
||||
var chrome_1 = require("./chrome");
|
||||
var chromium_1 = require("./chromium");
|
||||
var browsers = {
|
||||
chrome: chrome_1.default,
|
||||
canary: canary_1.default,
|
||||
chromium: chromium_1.default
|
||||
};
|
||||
exports.default = browsers;
|
||||
@@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var log_1 = require("../log");
|
||||
var execa = require("execa");
|
||||
var fs = require("fs-extra");
|
||||
var path = require("path");
|
||||
var plist = require("plist");
|
||||
function parse(p, prop) {
|
||||
var pl = path.join(p, 'Contents', 'Info.plist');
|
||||
return fs.readFile(pl, 'utf8')
|
||||
.then(function (str) { return plist.parse(str); })
|
||||
.then(function (x) { return x[prop]; })
|
||||
.catch(function (e) {
|
||||
var msg = "Info.plist not found: " + pl + "\n " + e.message;
|
||||
var err = new Error(msg);
|
||||
err.notInstalled = true;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
exports.parse = parse;
|
||||
function find(id) {
|
||||
var cmd = "mdfind 'kMDItemCFBundleIdentifier==\"" + id + "\"' | head -1";
|
||||
log_1.log('looking for bundle id %s using command: %s', id, cmd);
|
||||
return execa.shell(cmd)
|
||||
.then(function (result) { return result.stdout; })
|
||||
.then(function (str) {
|
||||
log_1.log('found %s at %s', id, str);
|
||||
return str;
|
||||
})
|
||||
.catch(function () {
|
||||
log_1.log('could not find %s', id);
|
||||
var err = new Error("Browser not installed: " + id);
|
||||
err.notInstalled = true;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
exports.find = find;
|
||||
@@ -1,71 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var linux_1 = require("./linux");
|
||||
var darwin_1 = require("./darwin");
|
||||
var log_1 = require("./log");
|
||||
var _ = require("lodash");
|
||||
var os = require("os");
|
||||
var Promise = require("bluebird");
|
||||
var browsers = [
|
||||
{
|
||||
name: 'chrome',
|
||||
re: /Google Chrome (\S+)/,
|
||||
profile: true,
|
||||
binary: 'google-chrome',
|
||||
executable: 'Contents/MacOS/Google Chrome'
|
||||
}, {
|
||||
name: 'chromium',
|
||||
re: /Chromium (\S+)/,
|
||||
profile: true,
|
||||
binary: 'chromium-browser',
|
||||
executable: 'Contents/MacOS/Chromium'
|
||||
}, {
|
||||
name: 'canary',
|
||||
re: /Google Chrome Canary (\S+)/,
|
||||
profile: true,
|
||||
binary: 'google-chrome-canary',
|
||||
executable: 'Contents/MacOS/Google Chrome Canary'
|
||||
}
|
||||
];
|
||||
var setMajorVersion = function (obj) {
|
||||
obj.majorVersion = obj.version.split('.')[0];
|
||||
log_1.log('browser %s version %s major version %s', obj.name, obj.version, obj.majorVersion);
|
||||
return obj;
|
||||
};
|
||||
function lookup(platform, obj) {
|
||||
log_1.log('looking up %s on %s platform', obj.name, platform);
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
var fn = darwin_1.default[obj.name];
|
||||
if (fn) {
|
||||
return fn.get(obj.executable);
|
||||
}
|
||||
var err = new Error("Browser not installed: " + obj.name);
|
||||
err.notInstalled = true;
|
||||
return Promise.reject(err);
|
||||
case 'linux':
|
||||
return linux_1.linuxBrowser.get(obj.binary, obj.re);
|
||||
}
|
||||
}
|
||||
function checkOneBrowser(browser) {
|
||||
var platform = os.platform();
|
||||
return lookup(platform, browser)
|
||||
.then(function (props) {
|
||||
return _.chain({})
|
||||
.extend(browser, props)
|
||||
.pick('name', 'type', 'version', 'path')
|
||||
.value();
|
||||
})
|
||||
.then(setMajorVersion)
|
||||
.catch(function (err) {
|
||||
if (err.notInstalled) {
|
||||
log_1.log('browser %s not installed', browser.name);
|
||||
return false;
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
module.exports = function () {
|
||||
return Promise.map(browsers, checkOneBrowser)
|
||||
.then(_.compact);
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var fs_extra_1 = require("fs-extra");
|
||||
var browsers_1 = require("./browsers");
|
||||
var Promise = require('bluebird');
|
||||
var detect = require('./detect');
|
||||
var missingConfig = function () {
|
||||
return Promise.reject(new Error('You must provide a path to a config file.'));
|
||||
};
|
||||
var wrap = function (all) { return ({
|
||||
launch: function (name, url, args) {
|
||||
if (args === void 0) { args = []; }
|
||||
return browsers_1.launch(all, name, url, args);
|
||||
}
|
||||
}); };
|
||||
var init = function (browsers) {
|
||||
return browsers ? wrap(browsers) : detect().then(wrap);
|
||||
};
|
||||
var api = init;
|
||||
var update = function (pathToConfig) {
|
||||
if (!pathToConfig) {
|
||||
return missingConfig();
|
||||
}
|
||||
// detect the browsers and set the config
|
||||
var saveBrowsers = function (browers) {
|
||||
return fs_extra_1.writeJson(pathToConfig, browers, { spaces: 2 });
|
||||
};
|
||||
return detect()
|
||||
.then(saveBrowsers);
|
||||
};
|
||||
// extend "api" with a few utility methods for convenience
|
||||
api.update = update;
|
||||
api.detect = detect;
|
||||
module.exports = api;
|
||||
@@ -1,29 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var cp = require("child_process");
|
||||
var Promise = require("bluebird");
|
||||
var execAsync = Promise.promisify(cp.exec);
|
||||
var notInstalledErr = function (name) {
|
||||
var err = new Error("Browser not installed: " + name);
|
||||
err.notInstalled = true;
|
||||
throw err;
|
||||
};
|
||||
exports.linuxBrowser = {
|
||||
get: function (binary, re) {
|
||||
return execAsync(binary + " --version")
|
||||
.call('trim')
|
||||
.then(function (stdout) {
|
||||
var m = re.exec(stdout);
|
||||
if (m) {
|
||||
return {
|
||||
path: binary,
|
||||
version: m[1]
|
||||
};
|
||||
}
|
||||
else {
|
||||
notInstalledErr(binary);
|
||||
}
|
||||
})
|
||||
.catch(function () { return notInstalledErr(binary); });
|
||||
}
|
||||
};
|
||||
@@ -1,4 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var debug = require("debug");
|
||||
exports.log = debug('cypress:launcher');
|
||||
Reference in New Issue
Block a user