Clean the code a bit. Move comments to test to decrease dependency size Minify package.json for extra.
This commit is contained in:
parent
b5312312ba
commit
e866e58dda
7 changed files with 14 additions and 11 deletions
|
@ -27,6 +27,9 @@ jobs:
|
||||||
echo ""
|
echo ""
|
||||||
echo "------------------------------------"
|
echo "------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
mv package.json package-dev.json
|
||||||
|
mv package-build.json package.json
|
||||||
|
|
||||||
CURR_VER="$(cat package.json | jq -r .name)_v$(cat package.json | jq -r .version)"
|
CURR_VER="$(cat package.json | jq -r .name)_v$(cat package.json | jq -r .version)"
|
||||||
CURR_NAME="$(cat package.json | jq -r .name) v$(cat package.json | jq -r .version)"
|
CURR_NAME="$(cat package.json | jq -r .name) v$(cat package.json | jq -r .version)"
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ Returns true if inside CI. Otherwise returns false.
|
||||||
Returns code 0 if inside CI. Otherwise returns an error code of 1.
|
Returns code 0 if inside CI. Otherwise returns an error code of 1.
|
||||||
|
|
||||||
`inside-ci || echo 'We are not inside CI, install some stuff'`
|
`inside-ci || echo 'We are not inside CI, install some stuff'`
|
||||||
|
|
||||||
`inside-ci && echo 'We are inside CI, install some stuff'`
|
`inside-ci && echo 'We are inside CI, install some stuff'`
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
2
index.d.ts
vendored
2
index.d.ts
vendored
|
@ -1,2 +1,2 @@
|
||||||
/** Returns true if current environment is running inside CI. Otherwise returns false. */
|
/** Returns true if current environment is running inside CI. Otherwise returns false. */
|
||||||
export function insideCi()
|
export function insideCi(): boolean
|
||||||
|
|
10
index.js
10
index.js
|
@ -1,18 +1,10 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/** Returns true if current environment is running inside CI. Otherwise returns false. */
|
|
||||||
function insideCi() {
|
function insideCi() {
|
||||||
// Bail out if this is specifically overwritten to false.
|
// Bail out if this is specifically overwritten to false.
|
||||||
// Some users seem to wanna be able to do that
|
|
||||||
if (process.env.CI === 'false') return false
|
if (process.env.CI === 'false') return false
|
||||||
|
|
||||||
// Most CI use env.CI (travis, Gitlab, etc.)
|
return !!['CI','CI_APP_ID','BUILD_NUMBER','CI_NAME','RUN_ID'].some(x => process.env[x])
|
||||||
// There are some exceptions though:
|
|
||||||
// CI_APP_ID is used by Appflow: https://ionic.io/docs/appflow/package/environments#predefined-environments
|
|
||||||
// CI_NAME is used by Codeship:https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables
|
|
||||||
// BUILD_NUMBER is used by TeamCity: https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters
|
|
||||||
// RUN_ID is used by Taskcluster: https://docs.taskcluster.net/docs/reference/workers/docker-worker/environment
|
|
||||||
return Boolean(['CI','CI_APP_ID','BUILD_NUMBER','CI_NAME','RUN_ID'].some(x => process.env[x]))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.insideCi = insideCi
|
module.exports.insideCi = insideCi
|
||||||
|
|
1
package-build.json
Normal file
1
package-build.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"name":"inside-ci","version":"1.0.1","description":"Quick tool to check if we are inside CI","main":"index.js","bin":{"inside-ci":"./index.js"},"repository":{"type":"git","url":"https://git.nfp.is/TheThing/inside-ci.git"},"keywords":["ci","is-ci","inside-ci","environment"],"author":"Jonatan Nilsson","license":"WTFPL","files":["index.js","index.d.ts","README.md","LICENSE"]}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "inside-ci",
|
"name": "inside-ci",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "Quick tool to check if we are inside CI",
|
"description": "Quick tool to check if we are inside CI",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
6
test.mjs
6
test.mjs
|
@ -3,6 +3,12 @@ import { Eltro as t, assert } from 'eltro'
|
||||||
import { insideCi } from './index.js'
|
import { insideCi } from './index.js'
|
||||||
|
|
||||||
t.describe('#insideCi()', function () {
|
t.describe('#insideCi()', function () {
|
||||||
|
// Most CI use env.CI (travis, Gitlab, etc.)
|
||||||
|
// There are some exceptions though:
|
||||||
|
// CI_APP_ID is used by Appflow: https://ionic.io/docs/appflow/package/environments#predefined-environments
|
||||||
|
// CI_NAME is used by Codeship:https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables
|
||||||
|
// BUILD_NUMBER is used by TeamCity: https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters
|
||||||
|
// RUN_ID is used by Taskcluster: https://docs.taskcluster.net/docs/reference/workers/docker-worker/environment
|
||||||
const testVariables = [
|
const testVariables = [
|
||||||
'CI',
|
'CI',
|
||||||
'CI_APP_ID',
|
'CI_APP_ID',
|
||||||
|
|
Loading…
Reference in a new issue