Socket
Socket
Sign inDemoInstall

ci-env

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.9.0 to 1.10.0

7

index.js

@@ -67,5 +67,6 @@ let drone = require('./utils/drone')

event = 'push'
sha = ''
pull_request_number = ''
pull_request_number = process.env.CI_PR_NUMBER
sha=process.env.CI_COMMIT_ID,
buildUrl=process.env.CI_BUILD_URL
ci = 'codeship'

@@ -72,0 +73,0 @@ } else if (process.env.GITHUB_ACTION) {

{
"name": "ci-env",
"version": "1.9.0",
"version": "1.10.0",
"description": "Environment variables exposed by CI tools",

@@ -19,3 +19,3 @@ "main": "index.js",

"devDependencies": {
"ava": "0.25.0"
"ava": "2.2.0"
},

@@ -22,0 +22,0 @@ "repository": {

@@ -1,20 +0,38 @@

const test = require('ava')
const test = require("ava");
const { buildUrl, jobUrl, repo, sha, event, commit_message, pull_request_number, branch, ci } = require('./index')
const {
buildUrl,
jobUrl,
repo,
sha,
event,
commit_message,
pull_request_number,
branch,
ci
} = require("./index");
if (ci) {
console.log('values: ', { repo, sha, event, commit_message, pull_request_number, branch, ci })
console.log("values: ", {
repo,
sha,
event,
commit_message,
pull_request_number,
branch,
ci
});
test('ci is correctly set', t => {
if (process.env.TRAVIS) t.is(ci, 'travis')
else if (process.env.CIRCLECI) t.is(ci, 'circle')
else if (process.env.WERCKER) t.is(ci, 'wercker')
else if (process.env.DRONE) t.is(ci, 'drone')
else if (process.env.CI_NAME === 'codeship') t.is(ci, 'codeship')
else if (process.env.GITHUB_ACTION) t.is(ci, 'github_actions')
})
test("ci is correctly set", t => {
if (process.env.TRAVIS) t.is(ci, "travis");
else if (process.env.CIRCLECI) t.is(ci, "circle");
else if (process.env.WERCKER) t.is(ci, "wercker");
else if (process.env.DRONE) t.is(ci, "drone");
else if (process.env.CI_NAME === "codeship") t.is(ci, "codeship");
else if (process.env.GITHUB_ACTION) t.is(ci, "github_actions");
});
test('repo is correctly set', t => t.is(repo, 'siddharthkp/ci-env'))
test("repo is correctly set", t => t.is(repo, "siddharthkp/ci-env"));
test('sha is set', t => {
test("sha is set", t => {
const real_sha =

@@ -26,8 +44,8 @@ process.env.TRAVIS_PULL_REQUEST_SHA ||

process.env.DRONE_COMMIT ||
process.env.GITHUB_SHA
process.env.GITHUB_SHA;
t.is(sha, real_sha)
})
t.is(sha, real_sha);
});
test('commit_message is set', t => {
test("commit_message is set", t => {
const real_commit_message =

@@ -37,11 +55,11 @@ process.env.TRAVIS_COMMIT_MESSAGE ||

process.env.CI_MESSAGE ||
''
"";
// Only travis and codeship set commit message
t.is(commit_message, real_commit_message)
})
t.is(commit_message, real_commit_message);
});
test('pull_request_number is set', t => {
let circlePullRequestNumber
test("pull_request_number is set", t => {
let circlePullRequestNumber;
if (process.env.CI_PULL_REQUEST)
circlePullRequestNumber = process.env.CI_PULL_REQUEST.split('/').pop()
circlePullRequestNumber = process.env.CI_PULL_REQUEST.split("/").pop();

@@ -52,29 +70,41 @@ const real_pull_request_number =

circlePullRequestNumber ||
'' // wercker does not expose pull request number
""; // wercker does not expose pull request number
t.is(pull_request_number, real_pull_request_number)
})
t.is(pull_request_number, real_pull_request_number);
});
test('jobUrl is set', t => {
let real_jobUrl
if (process.env.TRAVIS) real_jobUrl = `https://travis-ci.org/${repo}/jobs/${process.env.TRAVIS_JOB_ID}`
t.is(jobUrl, real_jobUrl)
})
test("jobUrl is set", t => {
let real_jobUrl;
if (process.env.TRAVIS)
real_jobUrl = `https://travis-ci.org/${repo}/jobs/${
process.env.TRAVIS_JOB_ID
}`;
t.is(jobUrl, real_jobUrl);
});
test('buildUrl is set', t => {
let real_buildUrl
if (process.env.TRAVIS) real_buildUrl = `https://travis-ci.org/${repo}/builds/${process.env.TRAVIS_JOB_ID}`
t.is(buildUrl, real_buildUrl)
})
test("buildUrl is set", t => {
let real_buildUrl;
if (process.env.TRAVIS)
real_buildUrl = `https://travis-ci.org/${repo}/builds/${
process.env.TRAVIS_JOB_ID
}`;
t.is(buildUrl, real_buildUrl);
});
test('event is correctly set', t => {
if ((ci === 'travis' && process.env.TRAVIS_EVENT_TYPE === 'pull_request') ||
(ci === 'github_actions' && process.env.GITHUB_EVENT_NAME === 'pull_request'))
t.is(event, 'pull_request')
else t.is(event, 'push')
})
test("event is correctly set", t => {
if (
(ci === "travis" && process.env.TRAVIS_EVENT_TYPE === "pull_request") ||
(ci === "github_actions" &&
process.env.GITHUB_EVENT_NAME === "pull_request")
)
t.is(event, "pull_request");
else t.is(event, "push");
});
test('branch is correctly set', t => {
if (event === 'pull_request') t.is(branch, process.env.TRAVIS_PULL_REQUEST_BRANCH ||
process.env.GITHUB_REF)
test("branch is correctly set", t => {
if (event === "pull_request")
t.is(
branch,
process.env.TRAVIS_PULL_REQUEST_BRANCH || process.env.GITHUB_REF
);
else {

@@ -87,10 +117,9 @@ const real_branch =

process.env.CI_BRANCH || // codeship
process.env.GITHUB_REF
process.env.GITHUB_REF;
t.is(branch, real_branch)
t.is(branch, real_branch);
}
})
});
} else {
console.log('These tests can only run in CI environments')
test(t => t.pass())
test.skip("These tests can only run in CI environments", t => t.pass());
}

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