【问题标题】:Deno: How to allow read permission for directory/folderDeno:如何允许目录/文件夹的读取权限
【发布时间】:2020-05-22 14:33:12
【问题描述】:

看着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


    【解决方案1】:

    我想我找到了问题所在。首先,您需要使用= 添加允许的路径,如下所示:

    deno run --allow-read=src/ main.ts
    

    但它仍然无法工作,而且似乎是一个错误/增强功能。

    在你的脚本上你需要提供绝对路径然后才会生效:

    const watcher = Deno.watchFs("<ABSOLUTE_PATH>/src");
    

    对我来说这是Deno.watchFs() 方法的一个问题,我在 Github 上打开了一个:

    https://github.com/denoland/deno/issues/5742

    【讨论】:

    • 谢谢 - 我也明白我可以使用 --allow-read 而无需明确设置任何参数 - 但这也很有趣 - 谢谢
    猜你喜欢
    • 2020-09-04
    • 2012-02-04
    • 1970-01-01
    • 2017-04-02
    • 2013-03-20
    • 1970-01-01
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多