paneful 0.2.0 → 0.4.0
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/dist/server/index.js
CHANGED
|
@@ -237,24 +237,37 @@ function startServer(devMode, port) {
|
|
|
237
237
|
}
|
|
238
238
|
return best?.path ?? candidates[0];
|
|
239
239
|
};
|
|
240
|
+
const respond = (resolved) => {
|
|
241
|
+
if (!resolved) {
|
|
242
|
+
res.json({ path: null });
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
const isDirectory = fs.statSync(resolved).isDirectory();
|
|
247
|
+
res.json({ path: resolved, isDirectory });
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
res.json({ path: resolved, isDirectory: false });
|
|
251
|
+
}
|
|
252
|
+
};
|
|
240
253
|
if (process.platform === 'darwin') {
|
|
241
254
|
execFile('mdfind', [`kMDItemFSName == '${name.replace(/'/g, "\\'")}'`], (err, stdout) => {
|
|
242
255
|
if (err) {
|
|
243
|
-
|
|
256
|
+
respond(null);
|
|
244
257
|
return;
|
|
245
258
|
}
|
|
246
259
|
const candidates = stdout.trim().split('\n').filter(Boolean);
|
|
247
|
-
|
|
260
|
+
respond(findBest(candidates));
|
|
248
261
|
});
|
|
249
262
|
}
|
|
250
263
|
else {
|
|
251
264
|
execFile('locate', ['-l', '20', '-b', `\\${name}`], (err, stdout) => {
|
|
252
265
|
if (err) {
|
|
253
|
-
|
|
266
|
+
respond(null);
|
|
254
267
|
return;
|
|
255
268
|
}
|
|
256
269
|
const candidates = stdout.trim().split('\n').filter(Boolean);
|
|
257
|
-
|
|
270
|
+
respond(findBest(candidates));
|
|
258
271
|
});
|
|
259
272
|
}
|
|
260
273
|
});
|