envstash-cli 0.4.2 → 0.4.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envstash-cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Git-style CLI for EnvStash — keep your .env files in sync with your cloud account.",
5
5
  "keywords": [
6
6
  "env",
@@ -1,4 +1,4 @@
1
- import { execFile } from 'node:child_process'
1
+ import { spawn } from 'node:child_process'
2
2
  import { hostname, userInfo } from 'node:os'
3
3
  import { setTimeout as sleep } from 'node:timers/promises'
4
4
 
@@ -53,7 +53,12 @@ export async function login(flags) {
53
53
  out()
54
54
  out(` Your code: ${style.bold(style.cyan(started.userCode))}`)
55
55
  out()
56
- out(` ${style.dim('Open')} ${style.blue(verificationUrl ?? `${host}/cli`)}`)
56
+ // The URL on its own line, in the same visible cyan as the code above it:
57
+ // blue vanishes on dark terminals, and a line that is only the URL is what
58
+ // lets a terminal's double-click and link detection grab the whole thing.
59
+ out(` ${style.dim('Open this link to approve:')}`)
60
+ out()
61
+ out(` ${style.cyan(verificationUrl ?? `${host}/cli`)}`)
57
62
  out()
58
63
 
59
64
  if (!verificationUrl) {
@@ -217,8 +222,23 @@ function openBrowser(url) {
217
222
  }
218
223
 
219
224
  try {
220
- child = execFile(command.file, command.args, { stdio: 'ignore' }, error => settle(!error))
225
+ // spawn, not execFile: execFile builds its own options object for spawn
226
+ // and does not forward `stdio`, so asking it for 'ignore' silently got
227
+ // the default three pipes instead. The opener passes those on to the
228
+ // browser it exec-s, and child.unref() releases the process handle but
229
+ // not the pipe handles — so the event loop stayed alive on a browser that
230
+ // could outlive the terminal, and `envs login` printed "✓ Signed in" and
231
+ // then hung at the prompt. Detaching as well puts the browser in its own
232
+ // process group, so Ctrl-C on a still-waiting login does not take it down
233
+ // (not on Windows, where detached means a new console window).
234
+ child = spawn(command.file, command.args, {
235
+ stdio: 'ignore',
236
+ detached: process.platform !== 'win32',
237
+ windowsHide: true,
238
+ })
239
+
221
240
  child.on('error', () => settle(false))
241
+ child.on('exit', code => settle(code === 0))
222
242
  } catch {
223
243
  settle(false)
224
244
  return