@dotenvx/dotenvx 2.28.2 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +47 -12
  3. package/package.json +3 -3
  4. package/src/cli/actions/armor/down.js +1 -1
  5. package/src/cli/actions/armor/move.js +1 -1
  6. package/src/cli/actions/armor/open.js +1 -1
  7. package/src/cli/actions/armor/pull.js +1 -1
  8. package/src/cli/actions/armor/push.js +1 -1
  9. package/src/cli/actions/armor/up.js +1 -1
  10. package/src/cli/actions/curl.js +2 -2
  11. package/src/cli/actions/decrypt.js +4 -10
  12. package/src/cli/actions/define.js +1 -1
  13. package/src/cli/actions/del.js +3 -5
  14. package/src/cli/actions/encrypt.js +4 -10
  15. package/src/cli/actions/ext/genexample.js +1 -1
  16. package/src/cli/actions/ext/gitignore.js +1 -0
  17. package/src/cli/actions/ext/prebuild.js +5 -28
  18. package/src/cli/actions/ext/precommit.js +8 -3
  19. package/src/cli/actions/ext/scan.js +2 -3
  20. package/src/cli/actions/get.js +4 -7
  21. package/src/cli/actions/keychain/down.js +1 -1
  22. package/src/cli/actions/keychain/pull.js +1 -1
  23. package/src/cli/actions/keychain/push.js +1 -1
  24. package/src/cli/actions/keychain/up.js +1 -1
  25. package/src/cli/actions/keypair.js +3 -3
  26. package/src/cli/actions/lock/down.js +2 -3
  27. package/src/cli/actions/lock/up.js +2 -3
  28. package/src/cli/actions/login.js +2 -2
  29. package/src/cli/actions/logout.js +1 -1
  30. package/src/cli/actions/ls.js +1 -1
  31. package/src/cli/actions/protect.js +75 -0
  32. package/src/cli/actions/protectDocker.js +30 -0
  33. package/src/cli/actions/protectProcess.js +126 -0
  34. package/src/cli/actions/protectStdin.js +64 -0
  35. package/src/cli/actions/run.js +5 -6
  36. package/src/cli/actions/set.js +5 -9
  37. package/src/cli/actions/settings/device.js +2 -2
  38. package/src/cli/actions/settings/hostname.js +2 -2
  39. package/src/cli/actions/settings/off.js +1 -1
  40. package/src/cli/actions/settings/on.js +1 -1
  41. package/src/cli/actions/settings/path.js +2 -2
  42. package/src/cli/actions/settings/token.js +2 -2
  43. package/src/cli/actions/settings/username.js +2 -2
  44. package/src/cli/actions/validate.js +2 -2
  45. package/src/cli/commandAction.js +16 -0
  46. package/src/cli/commands/armor.js +10 -9
  47. package/src/cli/commands/custody.js +6 -4
  48. package/src/cli/commands/ext.js +7 -7
  49. package/src/cli/commands/lock.js +3 -2
  50. package/src/cli/commands/native.js +5 -4
  51. package/src/cli/commands/settings.js +8 -7
  52. package/src/cli/dotenvx.js +31 -17
  53. package/src/cli/help.js +4 -3
  54. package/src/lib/events/backends/armor.js +31 -0
  55. package/src/lib/events/background.js +59 -0
  56. package/src/lib/events/catalog.js +14 -0
  57. package/src/lib/events/cli.js +40 -0
  58. package/src/lib/events/delivery.js +89 -0
  59. package/src/lib/events/index.js +73 -0
  60. package/src/lib/events/metadata.js +25 -0
  61. package/src/lib/events/sdk.js +44 -0
  62. package/src/lib/events/worker.js +29 -0
  63. package/src/lib/events/workerEnvironment.js +14 -0
  64. package/src/lib/helpers/checklist.js +50 -0
  65. package/src/lib/helpers/createProtectSpinner.js +13 -0
  66. package/src/lib/helpers/executeCommand.js +12 -1
  67. package/src/lib/helpers/hasPlaintextSecrets.js +7 -0
  68. package/src/lib/helpers/installPrecommitHook.js +1 -0
  69. package/src/lib/helpers/installProtectFilter.js +56 -0
  70. package/src/lib/helpers/installProtectIgnore.js +27 -0
  71. package/src/lib/helpers/logProtectedFiles.js +9 -0
  72. package/src/lib/helpers/precommitEnvPatterns.js +1 -0
  73. package/src/lib/helpers/prompts.js +24 -0
  74. package/src/lib/helpers/protectSettings.js +63 -0
  75. package/src/lib/helpers/removeLegacyProtectFilter.js +42 -0
  76. package/src/lib/helpers/uninstallPrecommitHook.js +66 -0
  77. package/src/lib/main.d.ts +14 -0
  78. package/src/lib/main.js +11 -3
  79. package/src/lib/services/prebuild.js +4 -5
  80. package/src/lib/services/precommit.js +2 -12
  81. package/src/cli/actions/ext/precommitClean.js +0 -21
  82. package/src/lib/helpers/installPrecommitFilter.js +0 -50
package/CHANGELOG.md CHANGED
@@ -2,7 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- [Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.28.2...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.30.0...main)
6
+
7
+ ## [2.23.0](https://github.com/dotenvx/dotenvx/compare/v2.29.0...v2.30.0) (2026-09-22)
8
+
9
+ ### Added
10
+
11
+ * Add support for secrets references as safe from `dotenvx protect` ([#985](https://github.com/dotenvx/dotenvx/pull/985))
12
+ * Add cli audit logging for Armor customers ([#983](https://github.com/dotenvx/dotenvx/pull/983))
13
+
14
+ ## [2.29.0](https://github.com/dotenvx/dotenvx/compare/v2.28.2...v2.29.0) (2026-09-21)
15
+
16
+ ### Added
17
+
18
+ * Add `dotenvx protect` to prevent plaintext .env files from being committed to code on a machine ([#980](https://github.com/dotenvx/dotenvx/pull/980))
19
+
20
+ ### Changed
21
+
22
+ * Deprecate `dotenvx gitignore`. Use `dotenvx protect`.
23
+ * Deprecate `dotenvx precommit`. Use `dotenvx protect`.
24
+ * Deprecate `dotenvx prebuild`. Use `dotenvx protect --docker`.
6
25
 
7
26
  ## [2.28.2](https://github.com/dotenvx/dotenvx/compare/v2.28.1...v2.28.2) (2026-09-19)
8
27
 
package/README.md CHANGED
@@ -2924,6 +2924,8 @@ $ dotenvx gitignore --pattern .env.keys
2924
2924
  </details>
2925
2925
  <details><summary>`precommit`</summary><br>
2926
2926
 
2927
+ Deprecated in favor of `dotenvx protect`. Existing hooks continue checking files and print a migration notice on each invocation. Run `dotenvx protect` inside the repository to install global staging protection and remove its recognized dotenvx hook block. Other hook commands are preserved; customized or shared hooks may require manual cleanup.
2928
+
2927
2929
  Prevent `.env` files from being committed to code.
2928
2930
 
2929
2931
  ```sh
@@ -2934,24 +2936,57 @@ $ dotenvx precommit
2934
2936
  </details>
2935
2937
  <details><summary>`precommit --install`</summary><br>
2936
2938
 
2937
- Install a pre-commit hook and a required Git clean filter in the current repository. The filter rejects plaintext `.env*` files before staging, including with `git add -A` or `git add -f`. Encrypted files pass through unchanged. `.env.example`, `.env.vault`, and `.env.x` retain their exemptions; `.env.keys*` files are always rejected.
2939
+ Install a pre-commit hook in the current repository:
2940
+
2941
+ ```sh
2942
+ $ dotenvx precommit --install
2943
+ ▣ dotenvx precommit installed [.git/hooks/pre-commit]
2944
+ ```
2945
+
2946
+ For protection during staging, use `dotenvx protect`.
2938
2947
 
2939
- The filter uses repository-local Git configuration and `info/attributes`; run the installer in each clone. Keep the installed dotenvx executable available, or staging protected files will fail. It does not inspect content already staged before installation, and local Git configuration can be overridden.
2948
+ </details>
2949
+ <details><summary>`precommit --uninstall`</summary><br>
2940
2950
 
2941
- To enable the clean filter for all existing and future repositories for your user, run this once, even outside a Git repository:
2951
+ Remove the installed dotenvx pre-commit hook without installing replacement protection:
2942
2952
 
2943
2953
  ```sh
2944
- $ dotenvx precommit --install --global
2954
+ $ dotenvx precommit --uninstall
2945
2955
  ```
2946
2956
 
2947
- This writes the filter configuration to your global Git config and adds the `.env*` rule to your global attributes file. It preserves an existing `core.attributesFile`; otherwise it uses `$XDG_CONFIG_HOME/git/attributes` or `~/.config/git/attributes`. It leaves hooks unchanged. Repository attributes and configuration can override the global protection. Use a persistent dotenvx installation: moving or removing its executable requires reinstalling the filter.
2957
+ This removes recognized dotenvx installer blocks while preserving other hook commands. It also supports `dotenvx ext precommit --uninstall`. Unrecognized, symlinked, or external shared hooks are left unchanged with a manual-cleanup message.
2958
+
2959
+ </details>
2960
+ <details><summary>`protect` (hidden)</summary><br>
2961
+
2962
+ For a Docker build-time check instead of Git setup, use `RUN dotenvx protect --docker` in your Dockerfile, or `RUN dotenvx protect --docker apps/backend` for a specific directory. This replaces `prebuild` with the same checks, without prompts or Git configuration changes. It does not edit Dockerfiles or prevent files from reaching the builder; use `.dockerignore` for that.
2963
+
2964
+ Install a required Git clean filter for all existing and future repositories for your user. Run this once, even outside a Git repository:
2948
2965
 
2949
2966
  ```sh
2950
- $ dotenvx precommit --install
2951
- ▣ dotenvx precommit installed [.git/hooks/pre-commit]
2952
- ▣ dotenvx required clean filter installed (blocks staging plaintext .env files)
2967
+ $ dotenvx protect
2968
+ ```
2969
+
2970
+ Interactive setup shows one checklist with both protections selected every time, even if you previously turned them off:
2971
+
2972
+ ```text
2973
+ Set protections
2974
+ ● Protect plaintext secrets from code commits (.env*)
2975
+ ● Protect private keys from code commits (.env.keys*)
2976
+
2977
+ Install protections
2953
2978
  ```
2954
2979
 
2980
+ Use arrow keys to move and Enter or Space to toggle a choice. The action row changes to **Install protections**, **Apply changes**, **Remove protections**, or **Done**. Press Enter on that row to apply. Unchecking removes that protection; clearing both reports `⛉ unprotected (none)`. Cancelling leaves settings unchanged.
2981
+
2982
+ The first installs the staging filter. The second adds `.env.keys*` to your global Git ignore file, preserving existing rules and any configured `core.excludesFile`. Otherwise, it uses `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`. This skips private-key files during normal adds; the filter still rejects forced adds when enabled. Only dotenvx-owned ignore rules are removed. Older or manually added `.env.keys*` rules without an ownership record require manual removal. Noninteractive and CI runs retain filter-only installation without prompting or removing existing protections.
2983
+
2984
+ When run inside a repository with the filter selected, this also removes recognized dotenvx pre-commit hook blocks and legacy repo-local `precommit --clean` filter registrations after global protection is successfully installed. Custom filter commands are preserved. Run it in each repository with an old hook or filter override to migrate that repository.
2985
+
2986
+ The filter rejects plaintext `.env*`, `*.env`, `.flaskenv`, `.dev.vars*`, and files directly inside `.env.d/` directories at any depth before staging, including with `git add -A` or `git add -f`. Encrypted files pass through unchanged. `.env.example`, `.env.vault`, and `.env.x` retain their exemptions; `.env.keys*` files are always rejected.
2987
+
2988
+ This writes the filter configuration to your global Git config and adds the env-file rules to your global attributes file. Re-run `dotenvx protect` with the filter selected to refresh it after upgrading or moving the executable. It preserves an existing `core.attributesFile`; otherwise it uses `$XDG_CONFIG_HOME/git/attributes` or `~/.config/git/attributes`. It does not inspect content already staged before installation. Repository attributes and configuration can override the global protection. Use a persistent dotenvx installation.
2989
+
2955
2990
  </details>
2956
2991
  <details><summary>`precommit directory`</summary><br>
2957
2992
 
@@ -2969,7 +3004,7 @@ $ dotenvx precommit apps/backend
2969
3004
  </details>
2970
3005
  <details><summary>`prebuild`</summary><br>
2971
3006
 
2972
- Prevent `.env` files from being built into your docker containers.
3007
+ Deprecated. Use `dotenvx protect --docker` for the same build-time check.
2973
3008
 
2974
3009
  Add it to your `Dockerfile`.
2975
3010
 
@@ -2982,14 +3017,14 @@ COPY --from=dotenv/dotenvx:latest /usr/local/bin/dotenvx /bin/local/bin
2982
3017
 
2983
3018
  # ... orther container commands
2984
3019
 
2985
- RUN dotenvx prebuild
3020
+ RUN dotenvx protect --docker
2986
3021
  CMD ["/usr/local/bin/dotenvx", "run", "--", "node", "index.js"]
2987
3022
  ```
2988
3023
 
2989
3024
  </details>
2990
3025
  <details><summary>`prebuild directory`</summary><br>
2991
3026
 
2992
- Prevent `.env` files from being built into your docker containers inside a specified path to a directory.
3027
+ Deprecated. Use `dotenvx protect --docker <directory>` for the same build-time check in a specified directory.
2993
3028
 
2994
3029
  Add it to your `Dockerfile`.
2995
3030
 
@@ -3002,7 +3037,7 @@ COPY --from=dotenv/dotenvx:latest /usr/local/bin/dotenvx /bin/local/bin
3002
3037
 
3003
3038
  # ... orther container commands
3004
3039
 
3005
- RUN dotenvx prebuild apps/backend
3040
+ RUN dotenvx protect --docker apps/backend
3006
3041
  CMD ["/usr/local/bin/dotenvx", "run", "--", "node", "apps/backend/index.js"]
3007
3042
  ```
3008
3043
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.28.2",
2
+ "version": "2.30.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a secure dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -45,7 +45,7 @@
45
45
  "scripts": {
46
46
  "standard": "standard",
47
47
  "standard:fix": "standard --fix",
48
- "test": "tap run --test-env=DOTENVX_NO_ARMOR=true --allow-empty-coverage --disable-coverage --timeout=60000",
48
+ "test": "tap run --test-env=DOTENVX_NO_ARMOR=true --allow-empty-coverage --allow-incomplete-coverage --disable-coverage --timeout=60000",
49
49
  "testshell": "shellspec --shell /bin/bash",
50
50
  "release:check": "npm test && npm run testshell",
51
51
  "prerelease": "npm run release:check",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "funding": "https://dotenvx.com",
56
56
  "dependencies": {
57
- "@dotenvx/primitives": "^3.0.2",
57
+ "@dotenvx/primitives": "^3.0.3",
58
58
  "@dotenvx/tooling": "^1.0.3",
59
59
  "global-agent": "^3.0.0",
60
60
  "node-forge": "^1.4.0",
@@ -31,7 +31,7 @@ async function down () {
31
31
  } catch (error) {
32
32
  if (spinner) spinner.stop()
33
33
  logger.error(error.message)
34
- process.exit(1)
34
+ return { exitCode: 1, error }
35
35
  }
36
36
  }
37
37
 
@@ -36,7 +36,7 @@ async function move () {
36
36
  } catch (error) {
37
37
  if (spinner) spinner.stop()
38
38
  logger.error(error.message)
39
- process.exit(1)
39
+ return { exitCode: 1, error }
40
40
  }
41
41
  }
42
42
 
@@ -21,7 +21,7 @@ async function open () {
21
21
  logger.success(`◌ opened (${keyDisplay})`)
22
22
  } catch (error) {
23
23
  logger.error(error.message)
24
- process.exit(1)
24
+ return { exitCode: 1, error }
25
25
  }
26
26
  }
27
27
 
@@ -31,7 +31,7 @@ async function pull () {
31
31
  } catch (error) {
32
32
  if (spinner) spinner.stop()
33
33
  logger.error(error.message)
34
- process.exit(1)
34
+ return { exitCode: 1, error }
35
35
  }
36
36
  }
37
37
 
@@ -31,7 +31,7 @@ async function push () {
31
31
  } catch (error) {
32
32
  if (spinner) spinner.stop()
33
33
  logger.error(error.message)
34
- process.exit(1)
34
+ return { exitCode: 1, error }
35
35
  }
36
36
  }
37
37
 
@@ -31,7 +31,7 @@ async function up () {
31
31
  } catch (error) {
32
32
  if (spinner) spinner.stop()
33
33
  logger.error(error.message)
34
- process.exit(1)
34
+ return { exitCode: 1, error }
35
35
  }
36
36
  }
37
37
 
@@ -58,10 +58,10 @@ async function curl () {
58
58
  const text = await response.body.text()
59
59
  console.log(outputBody(text))
60
60
 
61
- if (response.statusCode >= 400) process.exitCode = 1
61
+ if (response.statusCode >= 400) return { exitCode: 1 }
62
62
  } catch (error) {
63
63
  catchAndLog(error)
64
- process.exit(1)
64
+ return { exitCode: 1, error }
65
65
  }
66
66
  }
67
67
 
@@ -59,11 +59,7 @@ async function decrypt () {
59
59
  }
60
60
  }
61
61
 
62
- if (errorCount > 0) {
63
- process.exit(1)
64
- } else {
65
- process.exit(0) // exit early
66
- }
62
+ return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
67
63
  } else {
68
64
  try {
69
65
  const {
@@ -110,15 +106,13 @@ async function decrypt () {
110
106
  // do nothing - scenario when no .env files found
111
107
  }
112
108
 
113
- if (errorCount > 0) {
114
- process.exit(1)
115
- }
109
+ return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
116
110
  } catch (error) {
117
111
  if (spinner) spinner.stop()
118
112
  catchAndLog(error)
119
- process.exit(1)
113
+ return { exitCode: 1, error }
120
114
  }
121
115
  }
122
116
  }
123
117
 
124
- module.exports = decrypt
118
+ module.exports = require('../../lib/events/cli')('decrypt', decrypt)
@@ -12,6 +12,6 @@ module.exports = function define () {
12
12
  }
13
13
  } catch (error) {
14
14
  catchAndLog(error)
15
- process.exitCode = 1
15
+ return { exitCode: 1, error }
16
16
  }
17
17
  }
@@ -43,14 +43,12 @@ async function del (key) {
43
43
  // do nothing - scenario when no .env files found
44
44
  }
45
45
 
46
- if (errorCount > 0) {
47
- process.exit(1)
48
- }
46
+ return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
49
47
  } catch (error) {
50
48
  if (spinner) spinner.stop()
51
49
  catchAndLog(error)
52
- process.exit(1)
50
+ return { exitCode: 1, error }
53
51
  }
54
52
  }
55
53
 
56
- module.exports = del
54
+ module.exports = require('../../lib/events/cli')('del', del)
@@ -43,11 +43,7 @@ async function encryptAction () {
43
43
  }
44
44
  }
45
45
 
46
- if (errorCount > 0) {
47
- process.exit(1)
48
- } else {
49
- process.exit(0) // exit early
50
- }
46
+ return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
51
47
  }
52
48
 
53
49
  try {
@@ -84,14 +80,12 @@ async function encryptAction () {
84
80
  // do nothing - scenario when no .env files found
85
81
  }
86
82
 
87
- if (errorCount > 0) {
88
- process.exit(1)
89
- }
83
+ return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
90
84
  } catch (error) {
91
85
  if (spinner) spinner.stop()
92
86
  catchAndLog(error)
93
- process.exit(1)
87
+ return { exitCode: 1, error }
94
88
  }
95
89
  }
96
90
 
97
- module.exports = encryptAction
91
+ module.exports = require('../../lib/events/cli')('encrypt', encryptAction)
@@ -29,7 +29,7 @@ function genexample (directory) {
29
29
  }
30
30
  } catch (error) {
31
31
  catchAndLog(error)
32
- process.exit(1)
32
+ return { exitCode: 1, error }
33
33
  }
34
34
  }
35
35
 
@@ -86,6 +86,7 @@ class Vercel {
86
86
  }
87
87
 
88
88
  function gitignore () {
89
+ logger.warn('[DEPRECATED] dotenvx gitignore. fix: run [dotenvx protect]')
89
90
  const options = this.opts()
90
91
  logger.debug(`options: ${JSON.stringify(options)}`)
91
92
 
@@ -1,30 +1,7 @@
1
- const { logger } = require('./../../../shared/logger')
1
+ const { logger } = require('../../../shared/logger')
2
+ const protectDocker = require('../../../lib/events/cli')('protect', require('../protectDocker'))
2
3
 
3
- const Prebuild = require('./../../../lib/services/prebuild')
4
- const catchAndLog = require('./../../../lib/helpers/catchAndLog')
5
-
6
- function prebuild (directory) {
7
- // debug args
8
- logger.debug(`directory: ${directory}`)
9
-
10
- const options = this.opts()
11
- logger.debug(`options: ${JSON.stringify(options)}`)
12
-
13
- try {
14
- const {
15
- successMessage,
16
- warnings
17
- } = new Prebuild(directory, options).run()
18
-
19
- for (const warning of warnings) {
20
- logger.warn(warning.messageWithHelp || warning.message)
21
- }
22
-
23
- logger.success(successMessage)
24
- } catch (error) {
25
- catchAndLog(error)
26
- process.exit(1)
27
- }
4
+ module.exports = function prebuild (directory) {
5
+ logger.warn('[DEPRECATED] dotenvx prebuild. fix: run [dotenvx protect --docker]')
6
+ return protectDocker.call(this, directory)
28
7
  }
29
-
30
- module.exports = prebuild
@@ -4,9 +4,6 @@ const Precommit = require('./../../../lib/services/precommit')
4
4
  const catchAndLog = require('./../../../lib/helpers/catchAndLog')
5
5
 
6
6
  function precommit (directory) {
7
- if (this.opts().clean !== undefined) {
8
- return require('./precommitClean')(this.opts().clean)
9
- }
10
7
  // debug args
11
8
  logger.debug(`directory: ${directory}`)
12
9
 
@@ -14,6 +11,14 @@ function precommit (directory) {
14
11
  logger.debug(`options: ${JSON.stringify(options)}`)
15
12
 
16
13
  try {
14
+ if (options.uninstall) {
15
+ if (options.install) throw new Error('--install and --uninstall cannot be used together')
16
+ const { removed, warning } = require('../../../lib/helpers/uninstallPrecommitHook')(directory)
17
+ if (warning) logger.warn(warning)
18
+ else logger.success(removed ? '▣ uninstalled (dotenvx precommit hook)' : '○ no dotenvx precommit hook found')
19
+ return
20
+ }
21
+ logger.warn('[DEPRECATED] dotenvx precommit. fix: run [dotenvx protect]')
17
22
  const {
18
23
  successMessage,
19
24
  warnings
@@ -14,8 +14,7 @@ function scan () {
14
14
  logger.error('gitleaks: command not found')
15
15
  logger.help('fix: install gitleaks: [brew install gitleaks]')
16
16
  logger.help('fix: other install options: [https://github.com/gitleaks/gitleaks]')
17
- process.exit(1)
18
- return
17
+ return { exitCode: 1, error }
19
18
  }
20
19
 
21
20
  let output = ''
@@ -27,7 +26,7 @@ function scan () {
27
26
  logger.error(chomp(error.stdout.toString()))
28
27
  }
29
28
 
30
- process.exit(1)
29
+ return { exitCode: 1, error }
31
30
  }
32
31
  }
33
32
 
@@ -118,18 +118,15 @@ async function get (key) {
118
118
  }
119
119
  }
120
120
 
121
- if (errorCount > 0) {
122
- process.exit(1)
123
- }
121
+ return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
124
122
  } catch (error) {
125
123
  if (spinner) spinner.stop()
126
124
  if (error.code === 'PROMPT_CANCELLED') {
127
- process.exit(130)
128
- return
125
+ return { exitCode: 130, error }
129
126
  }
130
127
  catchAndLog(error)
131
- process.exit(1)
128
+ return { exitCode: 1, error }
132
129
  }
133
130
  }
134
131
 
135
- module.exports = get
132
+ module.exports = require('../../lib/events/cli')('get', get)
@@ -23,7 +23,7 @@ async function down () {
23
23
  } catch (error) {
24
24
  if (spinner) spinner.stop()
25
25
  logger.error(error.message)
26
- process.exit(1)
26
+ return { exitCode: 1, error }
27
27
  }
28
28
  }
29
29
 
@@ -23,7 +23,7 @@ async function pull () {
23
23
  } catch (error) {
24
24
  if (spinner) spinner.stop()
25
25
  logger.error(error.message)
26
- process.exit(1)
26
+ return { exitCode: 1, error }
27
27
  }
28
28
  }
29
29
 
@@ -23,7 +23,7 @@ async function push () {
23
23
  } catch (error) {
24
24
  if (spinner) spinner.stop()
25
25
  logger.error(error.message)
26
- process.exit(1)
26
+ return { exitCode: 1, error }
27
27
  }
28
28
  }
29
29
 
@@ -23,7 +23,7 @@ async function up () {
23
23
  } catch (error) {
24
24
  if (spinner) spinner.stop()
25
25
  logger.error(error.message)
26
- process.exit(1)
26
+ return { exitCode: 1, error }
27
27
  }
28
28
  }
29
29
 
@@ -65,7 +65,7 @@ async function keypair (key) {
65
65
  } else {
66
66
  if (results === undefined) {
67
67
  console.log('')
68
- process.exit(1)
68
+ return { exitCode: 1 }
69
69
  } else if (options.format === 'colon' && key) {
70
70
  console.log(`${key}:${results}`)
71
71
  } else {
@@ -75,8 +75,8 @@ async function keypair (key) {
75
75
  } catch (error) {
76
76
  if (spinner) spinner.stop()
77
77
  catchAndLog(error)
78
- process.exit(1)
78
+ return { exitCode: 1, error }
79
79
  }
80
80
  }
81
81
 
82
- module.exports = keypair
82
+ module.exports = require('../../lib/events/cli')('keypair', keypair)
@@ -42,12 +42,11 @@ async function down () {
42
42
  }
43
43
  } catch (error) {
44
44
  if (error.code === 'PROMPT_CANCELLED') {
45
- process.exit(130)
46
- return
45
+ return { exitCode: 130, error }
47
46
  }
48
47
 
49
48
  logger.error(error.message)
50
- process.exit(1)
49
+ return { exitCode: 1, error }
51
50
  }
52
51
  }
53
52
 
@@ -50,12 +50,11 @@ async function up () {
50
50
  }
51
51
  } catch (error) {
52
52
  if (error.code === 'PROMPT_CANCELLED') {
53
- process.exit(130)
54
- return
53
+ return { exitCode: 130, error }
55
54
  }
56
55
 
57
56
  logger.error(error.message)
58
- process.exit(1)
57
+ return { exitCode: 1, error }
59
58
  }
60
59
  }
61
60
 
@@ -45,7 +45,7 @@ async function login () {
45
45
  cleanupOpenKeyListener()
46
46
  if (spinner) spinner.stop()
47
47
  logger.success(`◉ logged in (${data.username})`)
48
- process.exit(0)
48
+ return { exitCode: 0 }
49
49
  } catch (error) {
50
50
  cleanupOpenKeyListener()
51
51
  if (spinner) spinner.stop()
@@ -57,7 +57,7 @@ async function login () {
57
57
  if (error.stack) {
58
58
  logger.debug(error.stack)
59
59
  }
60
- process.exit(1)
60
+ return { exitCode: 1, error }
61
61
  }
62
62
  }
63
63
 
@@ -30,7 +30,7 @@ async function logout () {
30
30
  if (error.stack) {
31
31
  logger.debug(error.stack)
32
32
  }
33
- process.exit(1)
33
+ return { exitCode: 1, error }
34
34
  }
35
35
  }
36
36
 
@@ -69,7 +69,7 @@ async function ls (directory) {
69
69
  } catch (error) {
70
70
  if (spinner) spinner.stop()
71
71
  catchAndLog(error)
72
- process.exit(1)
72
+ return { exitCode: 1, error }
73
73
  }
74
74
  }
75
75