latex-stickies 1.3.3 → 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/build/icon.icns +0 -0
- package/build/icon.png +0 -0
- package/package.json +1 -1
- package/scripts/brand-electron.js +51 -4
package/build/icon.icns
CHANGED
|
Binary file
|
package/build/icon.png
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -18,6 +18,36 @@ 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';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Makes LaunchServices re-read a bundle.
|
|
35
|
+
*
|
|
36
|
+
* It caches an app's name from the first time it sees the path, and npm
|
|
37
|
+
* extracts Electron under a directory macOS indexes -- so it can record
|
|
38
|
+
* "Electron" before this script ever runs, and then keep showing that in the
|
|
39
|
+
* Dock however right the plist is. Renaming alone is not enough.
|
|
40
|
+
*/
|
|
41
|
+
function refreshLaunchServices(appPath) {
|
|
42
|
+
try {
|
|
43
|
+
execFileSync(
|
|
44
|
+
'/System/Library/Frameworks/CoreServices.framework/Frameworks'
|
|
45
|
+
+ '/LaunchServices.framework/Support/lsregister',
|
|
46
|
+
['-f', appPath],
|
|
47
|
+
{ stdio: 'ignore', timeout: 10000 }
|
|
48
|
+
);
|
|
49
|
+
} catch (_) { /* the name is still right; only the cache is stale */ }
|
|
50
|
+
}
|
|
21
51
|
|
|
22
52
|
function main() {
|
|
23
53
|
if (process.platform !== 'darwin') return; // only macOS names apps this way
|
|
@@ -42,15 +72,30 @@ function main() {
|
|
|
42
72
|
}
|
|
43
73
|
};
|
|
44
74
|
|
|
45
|
-
if (read('CFBundleName') === NAME)
|
|
75
|
+
if (read('CFBundleName') === NAME && read('CFBundleIdentifier') === APP_ID) {
|
|
76
|
+
// Already named, so a wrong name in the Dock can only be a stale cache.
|
|
77
|
+
refreshLaunchServices(appPath);
|
|
78
|
+
// Say so rather than exiting in silence. A user reporting "the Dock still
|
|
79
|
+
// says Electron" needs to know whether the rename failed or whether they
|
|
80
|
+
// are looking at an older instance still holding the single-instance lock.
|
|
81
|
+
if (process.env.LATEX_STICKIES_VERBOSE) {
|
|
82
|
+
console.log(`the Electron shell is already named "${NAME}"`);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
46
86
|
|
|
47
87
|
const backup = fs.readFileSync(plist);
|
|
48
88
|
try {
|
|
49
|
-
|
|
89
|
+
const fields = [
|
|
90
|
+
['CFBundleName', NAME],
|
|
91
|
+
['CFBundleDisplayName', NAME],
|
|
92
|
+
['CFBundleIdentifier', APP_ID],
|
|
93
|
+
];
|
|
94
|
+
for (const [key, value] of fields) {
|
|
50
95
|
try {
|
|
51
|
-
execFileSync('plutil', ['-replace', key, '-string',
|
|
96
|
+
execFileSync('plutil', ['-replace', key, '-string', value, plist]);
|
|
52
97
|
} catch (_) {
|
|
53
|
-
execFileSync('plutil', ['-insert', key, '-string',
|
|
98
|
+
execFileSync('plutil', ['-insert', key, '-string', value, plist]);
|
|
54
99
|
}
|
|
55
100
|
}
|
|
56
101
|
|
|
@@ -66,6 +111,8 @@ function main() {
|
|
|
66
111
|
});
|
|
67
112
|
execFileSync('codesign', ['--verify', appPath], { stdio: 'ignore' });
|
|
68
113
|
|
|
114
|
+
refreshLaunchServices(appPath);
|
|
115
|
+
|
|
69
116
|
console.log(`named the Electron shell "${NAME}"`);
|
|
70
117
|
} catch (err) {
|
|
71
118
|
fs.writeFileSync(plist, backup);
|