@sprigr/apps-app-sdk 0.8.1 → 0.8.2

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.
@@ -29,8 +29,9 @@
29
29
  *
30
30
  * sprigr-check-write-protection [--apps apps] [--warn] [--baseline f] [--write-baseline]
31
31
  */
32
- import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
32
+ import { existsSync, readFileSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
33
33
  import { join } from 'node:path';
34
+ import { pathToFileURL } from 'node:url';
34
35
 
35
36
  /**
36
37
  * A tool or action name that destroys, reverses money, or cannot be walked
@@ -182,8 +183,18 @@ export function run(argv, cwd = process.cwd()) {
182
183
  return { code: 0, lines };
183
184
  }
184
185
 
185
- const invokedDirectly = process.argv[1] && /check-write-protection\.mjs$/.test(process.argv[1]);
186
- if (invokedDirectly) {
186
+ // npm installs the bin as a SYMLINK named `sprigr-check-write-protection`, so
187
+ // process.argv[1] does not end in `.mjs`; resolve it before comparing, or the
188
+ // CLI silently does nothing when run through npx / pnpm exec (0.8.1 shipped
189
+ // that way and printed nothing at all).
190
+ function invokedDirectly() {
191
+ try {
192
+ return !!process.argv[1] && pathToFileURL(realpathSync(process.argv[1])).href === import.meta.url;
193
+ } catch {
194
+ return false;
195
+ }
196
+ }
197
+ if (invokedDirectly()) {
187
198
  const { code, lines } = run(process.argv.slice(2));
188
199
  for (const l of lines) (code ? console.error : console.log)(l);
189
200
  process.exit(code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprigr/apps-app-sdk",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",