This commit is contained in:
parent
95f00d8700
commit
d46e0d834e
9 changed files with 27 additions and 34 deletions
|
@ -27,8 +27,7 @@ jobs:
|
|||
echo ""
|
||||
echo "------------------------------------"
|
||||
echo ""
|
||||
mv package.json package-dev.json
|
||||
mv package-build.json package.json
|
||||
./build.sh
|
||||
|
||||
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)"
|
||||
|
|
5
build.sh
Executable file
5
build.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
mv package.json package.json.backup
|
||||
|
||||
jq -c 'pick(.name, .version, .description, .main, .bin, .repository, .keywords, .author, .license, .files)' package.json.backup > package.json
|
12
in.js
Executable file
12
in.js
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
let is = module.exports.insideCi = () => {
|
||||
// Bail out if CI is overrided
|
||||
return process.env.CI === 'false'
|
||||
? false
|
||||
: !!['CI','CI_APP_ID','BUILD_NUMBER','CI_NAME','RUN_ID'].some(x => process.env[x])
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
process.exit(is() ? 0 : 1)
|
||||
}
|
2
index.d.ts
vendored
2
index.d.ts
vendored
|
@ -1,2 +0,0 @@
|
|||
/** Returns true if current environment is running inside CI. Otherwise returns false. */
|
||||
export function insideCi(): boolean
|
14
index.js
14
index.js
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
function insideCi() {
|
||||
// Bail out if this is specifically overwritten to false.
|
||||
if (process.env.CI === 'false') return false
|
||||
|
||||
return !!['CI','CI_APP_ID','BUILD_NUMBER','CI_NAME','RUN_ID'].some(x => process.env[x])
|
||||
}
|
||||
|
||||
module.exports.insideCi = insideCi
|
||||
|
||||
if (require.main === module) {
|
||||
process.exit(insideCi() ? 0 : 1)
|
||||
}
|
5
not.js
5
not.js
|
@ -1,5 +1,2 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const { insideCi } = require("./index.js");
|
||||
|
||||
process.exit(!insideCi() ? 0 : 1)
|
||||
process.exit(!require("./in.js").insideCi() ? 0 : 1)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"name":"inside-ci","version":"1.1.0","description":"Quick tool to check if we are inside CI","main":"index.js","bin":{"inside-ci":"./index.js","in-ci":"./index.js","not-ci":"./not.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","not.js","index.d.ts","README.md","LICENSE"]}
|
13
package.json
13
package.json
|
@ -8,13 +8,13 @@
|
|||
"test:watch": "eltro -r dot -w test test.mjs"
|
||||
},
|
||||
"bin": {
|
||||
"inside-ci": "./index.js",
|
||||
"in-ci": "./index.js",
|
||||
"inside-ci": "./in.js",
|
||||
"in-ci": "./in.js",
|
||||
"not-ci": "./not.js"
|
||||
},
|
||||
"watch": {
|
||||
"test": {
|
||||
"patterns": ["index.js", "test.mjs"]
|
||||
"patterns": ["in.js", "test.mjs"]
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
|
@ -23,9 +23,7 @@
|
|||
},
|
||||
"keywords": [
|
||||
"ci",
|
||||
"is-ci",
|
||||
"inside-ci",
|
||||
"environment"
|
||||
"is-ci"
|
||||
],
|
||||
"author": "Jonatan Nilsson",
|
||||
"license": "WTFPL",
|
||||
|
@ -33,9 +31,8 @@
|
|||
"eltro": "^1.6.1"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"in.js",
|
||||
"not.js",
|
||||
"index.d.ts",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
]
|
||||
|
|
6
test.mjs
6
test.mjs
|
@ -1,6 +1,6 @@
|
|||
import { exec } from 'child_process'
|
||||
import { Eltro as t, assert } from 'eltro'
|
||||
import { insideCi } from './index.js'
|
||||
import { insideCi } from './in.js'
|
||||
|
||||
t.describe('#insideCi()', function () {
|
||||
// Most CI use env.CI (travis, Gitlab, etc.)
|
||||
|
@ -59,7 +59,7 @@ function runCommand(command, options) {
|
|||
|
||||
t.describe('CLI in-ci', function() {
|
||||
t.test('should return success/code 0 if CI is filled', async function () {
|
||||
let result = await runCommand('node index.js', {
|
||||
let result = await runCommand('node in.js', {
|
||||
env: { CI: 'true' }
|
||||
})
|
||||
|
||||
|
@ -67,7 +67,7 @@ t.describe('CLI in-ci', function() {
|
|||
})
|
||||
|
||||
t.test('should return error code 1 if CI is false', async function () {
|
||||
let result = await runCommand('node index.js', {
|
||||
let result = await runCommand('node in.js', {
|
||||
env: { CI: 'false' }
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue