Socket
Socket
Sign inDemoInstall

@cucumber/ci-environment

Package Overview
Dependencies
0
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.2 to 9.0.3

7

dist/cjs/src/detectCiEnvironment.d.ts

@@ -1,9 +0,4 @@

/// <reference types="node" />
import { CiEnvironment, Env } from './types.js';
export declare type SyncFileReader = (path: string) => Buffer;
export declare type GithubActionsEvent = {
after: string;
};
export default function detectCiEnvironment(env: Env, fileReader?: SyncFileReader): CiEnvironment | undefined;
export default function detectCiEnvironment(env: Env): CiEnvironment | undefined;
export declare function removeUserInfoFromUrl(value: string): string;
//# sourceMappingURL=detectCiEnvironment.d.ts.map

28

dist/cjs/src/detectCiEnvironment.js

@@ -32,9 +32,8 @@ "use strict";

var evaluateVariableExpression_js_1 = __importDefault(require("./evaluateVariableExpression.js"));
function detectCiEnvironment(env, fileReader) {
function detectCiEnvironment(env) {
var e_1, _a;
if (fileReader === void 0) { fileReader = fs_1.readFileSync; }
try {
for (var CiEnvironments_1 = __values(CiEnvironments_js_1.CiEnvironments), CiEnvironments_1_1 = CiEnvironments_1.next(); !CiEnvironments_1_1.done; CiEnvironments_1_1 = CiEnvironments_1.next()) {
var ciEnvironment = CiEnvironments_1_1.value;
var detected = detect(ciEnvironment, env, fileReader);
var detected = detect(ciEnvironment, env);
if (detected) {

@@ -68,5 +67,5 @@ return detected;

exports.removeUserInfoFromUrl = removeUserInfoFromUrl;
function detectGit(ciEnvironment, env, syncFileReader) {
function detectGit(ciEnvironment, env) {
var _a, _b, _c;
var revision = detectRevision(ciEnvironment, env, syncFileReader);
var revision = detectRevision(ciEnvironment, env);
if (!revision) {

@@ -83,17 +82,18 @@ return undefined;

}
function detectRevision(ciEnvironment, env, syncFileReader) {
var _a;
function detectRevision(ciEnvironment, env) {
var _a, _b, _c;
if (env.GITHUB_EVENT_NAME === 'pull_request') {
if (!env.GITHUB_EVENT_PATH)
throw new Error('GITHUB_EVENT_PATH not set');
var json = syncFileReader(env.GITHUB_EVENT_PATH).toString();
var json = (0, fs_1.readFileSync)(env.GITHUB_EVENT_PATH, 'utf-8');
var event_1 = JSON.parse(json);
if (!('after' in event_1)) {
throw new Error("No after property in ".concat(env.GITHUB_EVENT_PATH, ":\n").concat(JSON.stringify(event_1, null, 2)));
var revision = (_b = (_a = event_1.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.sha;
if (!revision) {
throw new Error("Could not find .pull_request.head.sha in ".concat(env.GITHUB_EVENT_PATH, ":\n").concat(JSON.stringify(event_1, null, 2)));
}
return event_1.after;
return revision;
}
return (0, evaluateVariableExpression_js_1.default)((_a = ciEnvironment.git) === null || _a === void 0 ? void 0 : _a.revision, env);
return (0, evaluateVariableExpression_js_1.default)((_c = ciEnvironment.git) === null || _c === void 0 ? void 0 : _c.revision, env);
}
function detect(ciEnvironment, env, syncFileReader) {
function detect(ciEnvironment, env) {
var url = (0, evaluateVariableExpression_js_1.default)(ciEnvironment.url, env);

@@ -106,5 +106,5 @@ if (url === undefined) {

var buildNumber = (0, evaluateVariableExpression_js_1.default)(ciEnvironment.buildNumber, env);
var git = detectGit(ciEnvironment, env, syncFileReader);
var git = detectGit(ciEnvironment, env);
return __assign({ name: ciEnvironment.name, url: url, buildNumber: buildNumber }, (git && { git: git }));
}
//# sourceMappingURL=detectCiEnvironment.js.map

@@ -29,3 +29,3 @@ "use strict";

var env = Object.fromEntries(entries);
var ciEnvironment = (0, index_js_1.default)(env, gitHubActionReader);
var ciEnvironment = (0, index_js_1.default)(env);
var expectedJson = fs_1.default.readFileSync("".concat(txt, ".json"), {

@@ -51,8 +51,2 @@ encoding: 'utf8',

});
var gitHubActionReader = function () {
var event = {
after: '2436f28fad432a895bfc595bce16e907144b0dc3',
};
return Buffer.from(JSON.stringify(event, null, 2), 'utf-8');
};
//# sourceMappingURL=acceptanceTest.js.map

@@ -1,9 +0,4 @@

/// <reference types="node" />
import { CiEnvironment, Env } from './types.js';
export declare type SyncFileReader = (path: string) => Buffer;
export declare type GithubActionsEvent = {
after: string;
};
export default function detectCiEnvironment(env: Env, fileReader?: SyncFileReader): CiEnvironment | undefined;
export default function detectCiEnvironment(env: Env): CiEnvironment | undefined;
export declare function removeUserInfoFromUrl(value: string): string;
//# sourceMappingURL=detectCiEnvironment.d.ts.map
import { readFileSync } from 'fs';
import { CiEnvironments } from './CiEnvironments.js';
import evaluateVariableExpression from './evaluateVariableExpression.js';
export default function detectCiEnvironment(env, fileReader = readFileSync) {
export default function detectCiEnvironment(env) {
for (const ciEnvironment of CiEnvironments) {
const detected = detect(ciEnvironment, env, fileReader);
const detected = detect(ciEnvironment, env);
if (detected) {

@@ -25,5 +25,5 @@ return detected;

}
function detectGit(ciEnvironment, env, syncFileReader) {
function detectGit(ciEnvironment, env) {
var _a, _b, _c;
const revision = detectRevision(ciEnvironment, env, syncFileReader);
const revision = detectRevision(ciEnvironment, env);
if (!revision) {

@@ -40,17 +40,18 @@ return undefined;

}
function detectRevision(ciEnvironment, env, syncFileReader) {
var _a;
function detectRevision(ciEnvironment, env) {
var _a, _b, _c;
if (env.GITHUB_EVENT_NAME === 'pull_request') {
if (!env.GITHUB_EVENT_PATH)
throw new Error('GITHUB_EVENT_PATH not set');
const json = syncFileReader(env.GITHUB_EVENT_PATH).toString();
const json = readFileSync(env.GITHUB_EVENT_PATH, 'utf-8');
const event = JSON.parse(json);
if (!('after' in event)) {
throw new Error(`No after property in ${env.GITHUB_EVENT_PATH}:\n${JSON.stringify(event, null, 2)}`);
const revision = (_b = (_a = event.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.sha;
if (!revision) {
throw new Error(`Could not find .pull_request.head.sha in ${env.GITHUB_EVENT_PATH}:\n${JSON.stringify(event, null, 2)}`);
}
return event.after;
return revision;
}
return evaluateVariableExpression((_a = ciEnvironment.git) === null || _a === void 0 ? void 0 : _a.revision, env);
return evaluateVariableExpression((_c = ciEnvironment.git) === null || _c === void 0 ? void 0 : _c.revision, env);
}
function detect(ciEnvironment, env, syncFileReader) {
function detect(ciEnvironment, env) {
const url = evaluateVariableExpression(ciEnvironment.url, env);

@@ -63,3 +64,3 @@ if (url === undefined) {

const buildNumber = evaluateVariableExpression(ciEnvironment.buildNumber, env);
const git = detectGit(ciEnvironment, env, syncFileReader);
const git = detectGit(ciEnvironment, env);
return Object.assign({ name: ciEnvironment.name, url,

@@ -66,0 +67,0 @@ buildNumber }, (git && { git }));

@@ -12,3 +12,3 @@ import assert from 'assert';

const env = Object.fromEntries(entries);
const ciEnvironment = detectCiEnvironment(env, gitHubActionReader);
const ciEnvironment = detectCiEnvironment(env);
const expectedJson = fs.readFileSync(`${txt}.json`, {

@@ -21,8 +21,2 @@ encoding: 'utf8',

});
const gitHubActionReader = () => {
const event = {
after: '2436f28fad432a895bfc595bce16e907144b0dc3',
};
return Buffer.from(JSON.stringify(event, null, 2), 'utf-8');
};
//# sourceMappingURL=acceptanceTest.js.map
{
"name": "@cucumber/ci-environment",
"version": "9.0.2",
"version": "9.0.3",
"description": "Detect CI Environment from environment variables",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc