latex-stickies 1.3.4 → 1.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latex-stickies",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Sticky notes for your desktop that render LaTeX and Markdown.",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -18,6 +18,17 @@ const fs = require('fs');
18
18
  const path = require('path');
19
19
 
20
20
  const NAME = 'LaTeX Stickies';
21
+ /**
22
+ * Our own bundle identifier, matching the packaged builds.
23
+ *
24
+ * The Electron shell ships as com.github.Electron, and LaunchServices keys its
25
+ * database by identifier rather than by path. So on a machine that has seen any
26
+ * other Electron -- another project's node_modules, an old npx copy, a
27
+ * different Electron app entirely -- the Dock can serve that record's name,
28
+ * "Electron", however carefully this script renames our copy. Taking our own
29
+ * identifier is what stops the collision; renaming alone cannot.
30
+ */
31
+ const APP_ID = 'com.kevinjusak.latexsticky';
21
32
 
22
33
  /**
23
34
  * Makes LaunchServices re-read a bundle.
@@ -61,7 +72,7 @@ function main() {
61
72
  }
62
73
  };
63
74
 
64
- if (read('CFBundleName') === NAME) {
75
+ if (read('CFBundleName') === NAME && read('CFBundleIdentifier') === APP_ID) {
65
76
  // Already named, so a wrong name in the Dock can only be a stale cache.
66
77
  refreshLaunchServices(appPath);
67
78
  // Say so rather than exiting in silence. A user reporting "the Dock still
@@ -75,11 +86,16 @@ function main() {
75
86
 
76
87
  const backup = fs.readFileSync(plist);
77
88
  try {
78
- for (const key of ['CFBundleName', 'CFBundleDisplayName']) {
89
+ const fields = [
90
+ ['CFBundleName', NAME],
91
+ ['CFBundleDisplayName', NAME],
92
+ ['CFBundleIdentifier', APP_ID],
93
+ ];
94
+ for (const [key, value] of fields) {
79
95
  try {
80
- execFileSync('plutil', ['-replace', key, '-string', NAME, plist]);
96
+ execFileSync('plutil', ['-replace', key, '-string', value, plist]);
81
97
  } catch (_) {
82
- execFileSync('plutil', ['-insert', key, '-string', NAME, plist]);
98
+ execFileSync('plutil', ['-insert', key, '-string', value, plist]);
83
99
  }
84
100
  }
85
101