octwin-cli 0.1.7 → 0.1.8
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/dist/index.js +14 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -177,11 +177,22 @@ async function latestPublishedVersion() {
|
|
|
177
177
|
return null;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
+
/** True when running via `npx` — the CLI's own file lives in npx's cache dir, or npm
|
|
181
|
+
* ran it as `npm exec`. Under npx there is no persistent install to upgrade
|
|
182
|
+
* (`@latest` already resolves the newest), so an upgrade notice would be
|
|
183
|
+
* misleading — stay silent. The notice is for a GLOBAL install (`npm i -g`). */
|
|
184
|
+
function isNpx() {
|
|
185
|
+
try {
|
|
186
|
+
return fileURLToPath(import.meta.url).includes('_npx') || process.env.npm_command === 'exec';
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
180
192
|
/** Print a one-line upgrade notice (to stderr) when a newer octwin-cli is published.
|
|
181
|
-
* Skipped when not
|
|
182
|
-
* Never throws. */
|
|
193
|
+
* Skipped when piped/CI (not a TTY) or run via npx (nothing to upgrade). Never throws. */
|
|
183
194
|
async function notifyIfOutdated() {
|
|
184
|
-
if (!process.stdout.isTTY)
|
|
195
|
+
if (!process.stdout.isTTY || isNpx())
|
|
185
196
|
return;
|
|
186
197
|
try {
|
|
187
198
|
const latest = await latestPublishedVersion();
|
package/package.json
CHANGED