UNPKG

@callstack/reassure-danger

Version:

Performance testing companion for React and React Native

59 lines (56 loc) 2.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dangerReassure = dangerReassure; var fs = _interopRequireWildcard(require("fs")); var path = _interopRequireWildcard(require("path")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * Declaring dangerjs API methods used in the plugin * --- * @function warn(message: string): void; * - displays a warning message in Danger's output in MR after CI pipeline finishes running * - does NOT stop the pipeline run itself * @function markdown(message: string): void; * - displays a markdown content in Danger's output in MR after CI pipeline finishes running * - allows for displaying messages in markdown format */ /** * Configuration object which can optionally be passed down to plugin's call. * By default, it will only pass the inputFilePath parameter */ function dangerReassure(config = { inputFilePath: '.reassure/output.md' }) { const _warning = ` ⚠️ No output file found @ ${config.inputFilePath} ------------------------------------------------------------- Review reassure configuration and make sure your markdown output file can be found in the location shown above. Alternatively, you can pass your markdown output file location to plugin's config object in your dangerfile. ------------------------------------------------------------- `; try { const perfFilePath = path.resolve(config.inputFilePath); const perfFileContents = fs.readFileSync(perfFilePath, 'utf8'); if (config.debug) { if (!perfFileContents) { console.log(_warning); } else { console.log(perfFileContents); } } else { if (!perfFileContents) { warn(_warning); } else { markdown(perfFileContents); } } } catch (error) { console.error(_warning, error); } } //# sourceMappingURL=dangerjs.js.map