有没有办法为 Deno 中的子目录授予读取权限?
Is there a way to give read permissions for a subdirectory in Deno?
我有一个脚本可以访问子目录中的文件。当您允许所有读取访问权限时,它会起作用,但我尝试仅授予对该目录的读取访问权限的所有尝试都失败了。有没有办法通过 --allow-read
的相对路径指定目录?
命令
deno run --allow-read=./resources .\testread.ts
仅授予您对子目录 ./resources
的读取权限
所以这有效:
const text1 = Deno.readTextFile("./resources/test.txt");
这会引发异常:
const text1 = Deno.readTextFile("./test.txt");
PermissionDenied: read access to "./test.txt", run again with the --allow-read flag
您还可以在逗号分隔列表中指定多个目录:
deno run --allow-read=./resources,./other .\testread.ts
如果您需要写入权限,其工作方式与读取权限相同:
deno run --allow-write=./resources,./other .\testread.ts
我有一个脚本可以访问子目录中的文件。当您允许所有读取访问权限时,它会起作用,但我尝试仅授予对该目录的读取访问权限的所有尝试都失败了。有没有办法通过 --allow-read
的相对路径指定目录?
命令
deno run --allow-read=./resources .\testread.ts
仅授予您对子目录 ./resources
所以这有效:
const text1 = Deno.readTextFile("./resources/test.txt");
这会引发异常:
const text1 = Deno.readTextFile("./test.txt");
PermissionDenied: read access to "./test.txt", run again with the --allow-read flag
您还可以在逗号分隔列表中指定多个目录:
deno run --allow-read=./resources,./other .\testread.ts
如果您需要写入权限,其工作方式与读取权限相同:
deno run --allow-write=./resources,./other .\testread.ts