Compare commits
2 commits
inside-ci_
...
master
Author | SHA1 | Date | |
---|---|---|---|
95f00d8700 | |||
6e6d989a50 |
5 changed files with 38 additions and 8 deletions
11
README.md
11
README.md
|
@ -10,14 +10,17 @@ Returns true if inside CI. Otherwise returns false.
|
||||||
|
|
||||||
# CLI
|
# CLI
|
||||||
|
|
||||||
`inside-ci`
|
## `inside-ci` or `in-ci`
|
||||||
|
|
||||||
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'`
|
||||||
|
* `in-ci && echo 'We are inside CI, install some stuff'`
|
||||||
`inside-ci && echo 'We are inside CI, install some stuff'`
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
`is-ci || husky install`
|
`is-ci || husky install`
|
||||||
|
|
||||||
|
## `not-ci`
|
||||||
|
|
||||||
|
Inverse of the above command
|
||||||
|
|
5
not.js
Executable file
5
not.js
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { insideCi } = require("./index.js");
|
||||||
|
|
||||||
|
process.exit(!insideCi() ? 0 : 1)
|
|
@ -1 +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"]}
|
{"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"]}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "inside-ci",
|
"name": "inside-ci",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"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": {
|
||||||
|
@ -8,7 +8,9 @@
|
||||||
"test:watch": "eltro -r dot -w test test.mjs"
|
"test:watch": "eltro -r dot -w test test.mjs"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"inside-ci": "./index.js"
|
"inside-ci": "./index.js",
|
||||||
|
"in-ci": "./index.js",
|
||||||
|
"not-ci": "./not.js"
|
||||||
},
|
},
|
||||||
"watch": {
|
"watch": {
|
||||||
"test": {
|
"test": {
|
||||||
|
@ -32,6 +34,7 @@
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
|
"not.js",
|
||||||
"index.d.ts",
|
"index.d.ts",
|
||||||
"README.md",
|
"README.md",
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
|
|
21
test.mjs
21
test.mjs
|
@ -57,7 +57,7 @@ function runCommand(command, options) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
t.describe('CLI', function() {
|
t.describe('CLI in-ci', function() {
|
||||||
t.test('should return success/code 0 if CI is filled', async 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 index.js', {
|
||||||
env: { CI: 'true' }
|
env: { CI: 'true' }
|
||||||
|
@ -75,3 +75,22 @@ t.describe('CLI', function() {
|
||||||
assert.strictEqual(result.err.code, 1)
|
assert.strictEqual(result.err.code, 1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.describe('CLI not-ci', function() {
|
||||||
|
t.test('should return error code 1 if CI is filled', async function () {
|
||||||
|
let result = await runCommand('node not.js', {
|
||||||
|
env: { CI: 'true' }
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.ok(result.err)
|
||||||
|
assert.strictEqual(result.err.code, 1)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.test('should return success/code 0 if CI is false', async function () {
|
||||||
|
let result = await runCommand('node not.js', {
|
||||||
|
env: { CI: 'false' }
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.notOk(result.err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue