Reputation: 33
I have a script that accesses files in a sub-directory. It works when you allow all read access, but all of my attempts at giving read access only to that directory have failed. Is there a way to specify directories via relative paths for --allow-read
?
Upvotes: 3
Views: 579
Reputation: 22535
The command
deno run --allow-read=./resources .\testread.ts
gives you read access only to the subdirectory ./resources
so this works:
const text1 = Deno.readTextFile("./resources/test.txt");
and this throws an exception:
const text1 = Deno.readTextFile("./test.txt");
PermissionDenied: read access to "./test.txt", run again with the --allow-read flag
You can also specify more than one directory in a comma separated list:
deno run --allow-read=./resources,./other .\testread.ts
If you need write access, it works the same way as for read access:
deno run --allow-write=./resources,./other .\testread.ts
Reference: https://deno.land/manual/getting_started/permissions
Upvotes: 6