latex-stickies 1.3.3 → 1.3.4

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/build/icon.icns CHANGED
Binary file
package/build/icon.png CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latex-stickies",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Sticky notes for your desktop that render LaTeX and Markdown.",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -19,6 +19,25 @@ const path = require('path');
19
19
 
20
20
  const NAME = 'LaTeX Stickies';
21
21
 
22
+ /**
23
+ * Makes LaunchServices re-read a bundle.
24
+ *
25
+ * It caches an app's name from the first time it sees the path, and npm
26
+ * extracts Electron under a directory macOS indexes -- so it can record
27
+ * "Electron" before this script ever runs, and then keep showing that in the
28
+ * Dock however right the plist is. Renaming alone is not enough.
29
+ */
30
+ function refreshLaunchServices(appPath) {
31
+ try {
32
+ execFileSync(
33
+ '/System/Library/Frameworks/CoreServices.framework/Frameworks'
34
+ + '/LaunchServices.framework/Support/lsregister',
35
+ ['-f', appPath],
36
+ { stdio: 'ignore', timeout: 10000 }
37
+ );
38
+ } catch (_) { /* the name is still right; only the cache is stale */ }
39
+ }
40
+
22
41
  function main() {
23
42
  if (process.platform !== 'darwin') return; // only macOS names apps this way
24
43
 
@@ -42,7 +61,17 @@ function main() {
42
61
  }
43
62
  };
44
63
 
45
- if (read('CFBundleName') === NAME) return; // already done
64
+ if (read('CFBundleName') === NAME) {
65
+ // Already named, so a wrong name in the Dock can only be a stale cache.
66
+ refreshLaunchServices(appPath);
67
+ // Say so rather than exiting in silence. A user reporting "the Dock still
68
+ // says Electron" needs to know whether the rename failed or whether they
69
+ // are looking at an older instance still holding the single-instance lock.
70
+ if (process.env.LATEX_STICKIES_VERBOSE) {
71
+ console.log(`the Electron shell is already named "${NAME}"`);
72
+ }
73
+ return;
74
+ }
46
75
 
47
76
  const backup = fs.readFileSync(plist);
48
77
  try {
@@ -66,6 +95,8 @@ function main() {
66
95
  });
67
96
  execFileSync('codesign', ['--verify', appPath], { stdio: 'ignore' });
68
97
 
98
+ refreshLaunchServices(appPath);
99
+
69
100
  console.log(`named the Electron shell "${NAME}"`);
70
101
  } catch (err) {
71
102
  fs.writeFileSync(plist, backup);