mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-14 11:10:22 -06:00
* 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>
56 lines
1.3 KiB
CoffeeScript
56 lines
1.3 KiB
CoffeeScript
_ = require("lodash")
|
|
Promise = require("bluebird")
|
|
pkg = require("@packages/root")
|
|
path = require("path")
|
|
api = require("./api")
|
|
user = require("./user")
|
|
system = require("./util/system")
|
|
|
|
## strip everything but the file name to remove any sensitive
|
|
## data in the path
|
|
pathRe = /'?((\/|\\+|[a-z]:\\)[^\s']+)+'?/ig
|
|
pathSepRe = /[\/\\]+/
|
|
fileNameRe = /[^\s'/]+\.\w+:?\d*$/i
|
|
stripPath = (text) ->
|
|
(text or "").replace pathRe, (path) ->
|
|
fileName = _.last(path.split(pathSepRe)) or ""
|
|
"<stripped-path>#{fileName}"
|
|
|
|
## POST https://api.cypress.io/exceptions
|
|
## sets request body
|
|
## err: {}
|
|
## version: {}
|
|
|
|
module.exports = {
|
|
getErr: (err) ->
|
|
{
|
|
name: stripPath(err.name)
|
|
message: stripPath(err.message)
|
|
stack: stripPath(err.stack)
|
|
}
|
|
|
|
getVersion: ->
|
|
pkg.version
|
|
|
|
getBody: (err) ->
|
|
system.info()
|
|
.then (systemInfo) =>
|
|
_.extend({
|
|
err: @getErr(err)
|
|
version: @getVersion()
|
|
}, systemInfo)
|
|
|
|
getAuthToken: ->
|
|
user.get().then (user) ->
|
|
user and user.authToken
|
|
|
|
create: (err) ->
|
|
if process.env["CYPRESS_INTERNAL_ENV"] isnt "production" or
|
|
process.env["CYPRESS_CRASH_REPORTS"] is "0"
|
|
return Promise.resolve()
|
|
|
|
Promise.join(@getBody(err), @getAuthToken())
|
|
.spread (body, authToken) ->
|
|
api.createCrashReport(body, authToken)
|
|
}
|