diff --git a/not.js b/not.js new file mode 100755 index 0000000..3c69b09 --- /dev/null +++ b/not.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +const { insideCi } = require("./index.js"); + +process.exit(!insideCi() ? 0 : 1) diff --git a/package-build.json b/package-build.json index 71bb684..122134e 100644 --- a/package-build.json +++ b/package-build.json @@ -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"]} \ No newline at end of file +{"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"]} \ No newline at end of file diff --git a/package.json b/package.json index 75082a1..8bfe31c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "inside-ci", - "version": "1.0.1", + "version": "1.1.0", "description": "Quick tool to check if we are inside CI", "main": "index.js", "scripts": { @@ -8,7 +8,9 @@ "test:watch": "eltro -r dot -w test test.mjs" }, "bin": { - "inside-ci": "./index.js" + "inside-ci": "./index.js", + "in-ci": "./index.js", + "not-ci": "./not.js" }, "watch": { "test": { @@ -32,6 +34,7 @@ }, "files": [ "index.js", + "not.js", "index.d.ts", "README.md", "LICENSE" diff --git a/test.mjs b/test.mjs index f06a2aa..a55c463 100644 --- a/test.mjs +++ b/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 () { let result = await runCommand('node index.js', { env: { CI: 'true' } @@ -75,3 +75,22 @@ t.describe('CLI', function() { 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) + }) +})