Trim the fat and fix typings
All checks were successful
/ deploy (push) Successful in 25s

Clean the code a bit.
Move comments to test to decrease dependency size
Minify package.json for extra.
This commit is contained in:
Jonatan Nilsson 2024-11-19 00:11:46 +00:00
parent b5312312ba
commit e866e58dda
7 changed files with 14 additions and 11 deletions

View file

@ -27,6 +27,9 @@ jobs:
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_NAME="$(cat package.json | jq -r .name) v$(cat package.json | jq -r .version)"

View file

@ -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.
`inside-ci || echo 'We are not inside CI, install some stuff'`
`inside-ci && echo 'We are inside CI, install some stuff'`
Example:

2
index.d.ts vendored
View file

@ -1,2 +1,2 @@
/** Returns true if current environment is running inside CI. Otherwise returns false. */
export function insideCi()
export function insideCi(): boolean

View file

@ -1,18 +1,10 @@
#!/usr/bin/env node
/** Returns true if current environment is running inside CI. Otherwise returns false. */
function insideCi() {
// 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
// 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
return Boolean(['CI','CI_APP_ID','BUILD_NUMBER','CI_NAME','RUN_ID'].some(x => process.env[x]))
return !!['CI','CI_APP_ID','BUILD_NUMBER','CI_NAME','RUN_ID'].some(x => process.env[x])
}
module.exports.insideCi = insideCi

1
package-build.json Normal file
View 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"]}

View file

@ -1,6 +1,6 @@
{
"name": "inside-ci",
"version": "1.0.0",
"version": "1.0.1",
"description": "Quick tool to check if we are inside CI",
"main": "index.js",
"scripts": {

View file

@ -3,6 +3,12 @@ import { Eltro as t, assert } from 'eltro'
import { insideCi } from './index.js'
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 = [
'CI',
'CI_APP_ID',