@lionad/safe-npx 0.2.0 → 0.2.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/snpx.js +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lionad/safe-npx",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Safe npx wrapper - lock to latest-1 version with 24h cache",
5
5
  "type": "module",
6
6
  "bin": {
package/snpx.js CHANGED
@@ -104,12 +104,14 @@ export function parseArgs(argv) {
104
104
  snpxFlags.fallbackStrategy = args[++i];
105
105
  } else if (arg.startsWith('--fallback-strategy=')) {
106
106
  snpxFlags.fallbackStrategy = arg.slice('--fallback-strategy='.length);
107
+ } else if (arg.startsWith('--')) {
108
+ throw new Error(`Unknown flag: ${arg}. Run 'snpx --help' for available options.`);
107
109
  } else {
108
110
  npxArgs.push(arg);
109
111
  if (!pkgName && !sawFirstPositional) {
110
- if (arg.startsWith('-')) {
111
- // npx flag; skip for package detection
112
- } else {
112
+ // Single-dash flags (e.g. -y) skip package detection;
113
+ // positional args undergo package name matching.
114
+ if (!arg.startsWith('-')) {
113
115
  sawFirstPositional = true;
114
116
  const latestMatch = arg.match(/^(@[^/]+\/[^@]+|[^@]+)@latest$/);
115
117
  if (latestMatch) {
@@ -263,14 +265,14 @@ export async function checkSelfUpdate() {
263
265
  try {
264
266
  const data = await fetchPackageMetadata(PKG_NAME);
265
267
  const latest = data['dist-tags']?.latest;
266
- if (!latest) return { hasUpdate: false, currentVersion: '0.2.0', latestVersion: null };
268
+ if (!latest) return { hasUpdate: false, currentVersion: '0.2.1', latestVersion: null };
267
269
 
268
- const currentVersion = '0.2.0'; // Should match package.json
270
+ const currentVersion = '0.2.1'; // Should match package.json
269
271
  const hasUpdate = latest !== currentVersion;
270
272
 
271
273
  return { hasUpdate, currentVersion, latestVersion: latest };
272
274
  } catch {
273
- return { hasUpdate: false, currentVersion: '0.2.0', latestVersion: null };
275
+ return { hasUpdate: false, currentVersion: '0.2.1', latestVersion: null };
274
276
  }
275
277
  }
276
278