@nemus-cli/nemus 0.10.0 → 0.12.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.
@@ -60,6 +60,10 @@ async function fetchLatestVersion(): Promise<string | null> {
60
60
  * This is designed to be non-blocking and best-effort — failures are silent.
61
61
  */
62
62
  export async function checkForUpdate(): Promise<string | null> {
63
+ // Opt-out: skip the check entirely (no cache read, no network) when the user
64
+ // asks for it. NEMUS_NO_UPDATE_CHECK is ours; NO_UPDATE_NOTIFIER is the
65
+ // de-facto convention several Node CLIs honor.
66
+ if (updateCheckDisabled(process.env)) return null;
63
67
  try {
64
68
  const currentVersion = getPackageVersion();
65
69
  const cache = await loadCache();
@@ -91,6 +95,17 @@ export async function checkForUpdate(): Promise<string | null> {
91
95
  }
92
96
  }
93
97
 
98
+ /**
99
+ * Whether the update check is opted out via env. A value is "set" unless it is
100
+ * empty or an explicit falsey token (`0`/`false`), so `NEMUS_NO_UPDATE_CHECK=0`
101
+ * does NOT disable the check. Pure + exported for testing.
102
+ */
103
+ export function updateCheckDisabled(env: NodeJS.ProcessEnv): boolean {
104
+ const isSet = (v: string | undefined) =>
105
+ v !== undefined && v !== '' && v !== '0' && v.toLowerCase() !== 'false';
106
+ return isSet(env.NEMUS_NO_UPDATE_CHECK) || isSet(env.NO_UPDATE_NOTIFIER);
107
+ }
108
+
94
109
  function formatUpdateMessage(current: string, latest: string): string {
95
110
  return `\x1b[33m[nemus] Update available: ${current} -> ${latest}. Run: npm install -g @nemus-cli/nemus@latest\x1b[0m`;
96
111
  }