Files
cypress/packages/launcher/index.js
Jennifer Shehane 2ba53f6837 Better handle reserved key CYPRESS_ENV being set by users to va… (#6437)
* Add warning when setting CYPRESS_ENV to non-production value

* Add warning and update error when setting CYPRESS_ENV in config to non-production value

* Update config test/to throw

* we want warning, not throw

* Rename env var to CYPRESS_INTERNAL_ENV + fix warning to actually warn when staging

* update cli snapshot to include new 'info' command

* yarn.lock

* removed the warning from config, is overboard on our own tests 😓

* cleanup from review

Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
2020-03-06 16:53:48 +06:30

42 lines
1.1 KiB
JavaScript

// @ts-check
// compile TypeScript files on the fly using
// Node require hook project
if (process.env.CYPRESS_INTERNAL_ENV !== 'production') {
require('@packages/ts/register')
}
const launcher = require('./lib/launcher')
module.exports = launcher
if (!module.parent) {
const Bluebird = require('bluebird')
// quick way to check if TS is working
/* eslint-disable no-console */
console.log('Launcher project exports')
console.log(launcher)
console.log('⛔️ please use it as a module, not from CLI')
if (process.argv.length > 2) {
const filenames = process.argv.slice(2)
Bluebird.each(filenames, (filename) => {
launcher.detectByPath(filename)
.then((foundBrowser) => {
console.log(` 👍 Found "${filename}":`, foundBrowser)
})
.catch((err) => {
console.log(` 👎 Couldn't find "${filename}:"`, err.message)
})
})
} else {
launcher.detect().then((browsers) => {
console.log('detected %s', browsers.length === 1 ? 'browser' : 'browsers')
console.log(browsers)
}, console.error)
}
/* eslint-enable no-console */
}