fix: plugins not listed (exe distribution only) https://github.com/rejetto/hfs/issues/72
Massimo Melina committed
Sep 8, 2022 at 01:20 UTC
1a2394c6e1840ce1a48e02e3f44286c4366fb5d4
3 files changed
+19
-4
src/plugins.ts
+14
-3
@@ -7,7 +7,18 @@ import pathLib, { join } from 'path'
7
import { API_VERSION, APP_PATH, COMPATIBLE_API_VERSION, PLUGINS_PUB_URI } from './const'
8
import * as Const from './const'
9
import Koa from 'koa'
10
-import { Callback, debounceAsync, Dict, getOrSet, onProcessExit, same, tryJson, wantArray, watchDir } from './misc'
10
+import {
11
+ adjustStaticPathForGlob,
12
+ Callback,
13
+ debounceAsync,
14
+ Dict,
15
+ getOrSet,
16
+ onProcessExit,
17
+ same,
18
+ tryJson,
19
+ wantArray,
20
+ watchDir
21
+} from './misc'
22
import { defineConfig, getConfig } from './config'
23
import { DirEntry } from './api.file_list'
24
import { VfsNode } from './vfs'
@@ -198,8 +209,8 @@ export async function rescan() {
209
console.debug('scanning plugins')
210
const found = []
211
const foundDisabled: typeof availablePlugins = {}
201
- const MASK = join(PATH, '*', 'plugin.js')
202
- for (const f of await glob([join(APP_PATH, MASK), MASK])) {
212
+ const MASK = PATH + '/*/plugin.js' // be sure to not use path.join as fast-glob doesn't work with \
213
+ for (const f of await glob([adjustStaticPathForGlob(APP_PATH) + '/' + MASK, MASK])) {
214
const id = f.split('/').slice(-2)[0]
215
if (id.endsWith(DISABLING_POSTFIX)) continue
216
if (!enablePlugins.get().includes(id)) {
src/util-files.ts
+5
@@ -73,6 +73,11 @@ export function isWindowsDrive(s?: string) {
73
return s && /^[a-zA-Z]:$/.test(s)
74
}
75
76
+// apply this to paths that may contain \ as separator (not supported by fast-glob) and other special chars to be escaped (parenthesis)
77
+export function adjustStaticPathForGlob(path: string) {
78
+ return glob.escapePath(path.replace(/\\/g, '/'))
79
+}
80
+
81
export async function* dirStream(path: string) {
82
const stats = await fs.stat(path)
83
if (!stats.isDirectory())
src/vfs.ts
-1
@@ -5,7 +5,6 @@ import { basename, join } from 'path'
5
import { isMatch } from 'micromatch'
6
import { dirStream, dirTraversal, enforceFinal, getOrSet, isDirectory, typedKeys } from './misc'
7
import Koa from 'koa'
8
-import glob from 'fast-glob'
8
import _ from 'lodash'
9
import { defineConfig, setConfig } from './config'
10
import { FORBIDDEN, IS_WINDOWS, UNAUTHORIZED } from './const'