Deno:如何允许 directory/folder 的读取权限
Deno: How to allow read permission for directory/folder
正在查看https://deno.land/manual/examples/file_system_events
这是下面的代码。
const watcher = Deno.watchFs("./src");
for await (const event of watcher) {
console.log(">>>> event", event);
// { kind: "create", paths: [ "/foo.txt" ] }
}
但是,当我尝试 --allow-read
权限时,我得到 error: Is a directory
deno run --allow-read src/ main.ts
error: Is a directory (os error 21)
如何确保对指定的 /src
文件夹允许显式权限 --allow-read
?
我知道我可以使用 -A
到 --allow-all
,但是,我想明确允许的权限。
我想我发现了问题。那么首先你需要使用 =
添加允许的路径,像这样:
deno run --allow-read=src/ main.ts
但是还是不行,好像是bug/enhancement。
在你的脚本中需要提供绝对路径才会生效:
const watcher = Deno.watchFs("<ABSOLUTE_PATH>/src");
对我来说,这是 Deno.watchFs()
方法的一个问题,我在 Github:
上打开了一个
正在查看https://deno.land/manual/examples/file_system_events 这是下面的代码。
const watcher = Deno.watchFs("./src");
for await (const event of watcher) {
console.log(">>>> event", event);
// { kind: "create", paths: [ "/foo.txt" ] }
}
但是,当我尝试 --allow-read
权限时,我得到 error: Is a directory
deno run --allow-read src/ main.ts
error: Is a directory (os error 21)
如何确保对指定的 /src
文件夹允许显式权限 --allow-read
?
我知道我可以使用 -A
到 --allow-all
,但是,我想明确允许的权限。
我想我发现了问题。那么首先你需要使用 =
添加允许的路径,像这样:
deno run --allow-read=src/ main.ts
但是还是不行,好像是bug/enhancement。
在你的脚本中需要提供绝对路径才会生效:
const watcher = Deno.watchFs("<ABSOLUTE_PATH>/src");
对我来说,这是 Deno.watchFs()
方法的一个问题,我在 Github: