Preserve executable file permission when generating from executable .ts file
See original GitHub issueAs many libraries ship executable files to help with testing or administration it is convenient to be able to keep the executable permission on UNIX like systems while generating .js files from .ts files. The creator of the library can provide a build script or manually keep the proper permissions in distributed generated library but this is sub-optimal
TypeScript Version: 2.9.2 Search Terms: file permissions executable
Expected behavior:
$ ll lib/jem_cli.ts
-rwxr-xr-x 1 omg omg 5.9K 30 Jul 12,58 lib/jem_cli.ts
$ tsc
TSFILE: ..../jem_cli.js
$ ll jem_cli.js
-rwxr-xr-x 1 omg omg 8.2K 30 Jul 13,23 jem_cli.js
Actual behavior:
$ ll lib/jem_cli.ts
-rwxr-xr-x 1 omg omg 5.9K 30 Jul 12,58 lib/jem_cli.ts
$ tsc
TSFILE: ..../jem_cli.js
$ ll jem_cli.js
-rw-r--r-- 1 omg omg 8.2K 30 Jul 13,23 jem_cli.js
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Preserve executable file permission when generating ... - GitHub
As many libraries ship executable files to help with testing or administration it is convenient to be able to keep the executable permission...
Read more >node.js - TypeScripts transpiles files which are non-executable
Changing file's permissions isn't typescript responsibility. Solution 1. Use a separate step in the build process in your package.json.
Read more >Deno nuggets: Run TypeScript file as executable script
Learn how to run TypeScript file as an executable script. ... First, change the permissions by adding execute permissions: $ chmod 744 app....
Read more >Getting Started with Executing TypeScript files in ts-node
1. Create a script called hello.ts, and populate the hello. · 2. Next, run the below command to make the script executable (...
Read more >How to manage/preserve file privileges during an online file ...
Is there a way (there is, the man of the link is able to do it) to send a bash script with executable...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I agree with @sdrsdr: changing the flags on emitted files is a violation of POLA: I would not expect the flags to be changed after compilation.
This is what I get after running
tsc
and sending output todist
folder:Definitely not what I expected.
tsc
seems to be emitting a file with the least amount of permissions. I’m uploading this file to Lambda and the Lambda executor can’t access the code:"EACCES: permission denied, open '/var/task/index.js'",
I can workaround this. However it is a violation of POLA in my opinion.
This is a bit more complicated: A single compilation host is used for complete compilation task. You can track all source and output files, but there is no one to one relation. You can make a map out of input files and their permissions and match in it the output filenames and act accordingly. This might lead to some performance degradation in huge projects, so I was thinking about adding an compiler option to enable this behavior and keeping it off by default. Also to keep the map small I’m thinking about “remembering” only the executable input files. This will bring the lookup time to almost zero, yet you have to lookup file permissions for every input file.