Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizable permissions on emitted files #16667

Closed
ORESoftware opened this issue Jun 21, 2017 · 10 comments
Closed

Allow customizable permissions on emitted files #16667

ORESoftware opened this issue Jun 21, 2017 · 10 comments
Labels
Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript

Comments

@ORESoftware
Copy link

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)

Expected behavior:

I would expect TypeScript / tsc to output .js and .d.ts files that were readable + executable, but not writable by default. Furthermore, I would expect there to be options in tsconfig.json files, to allow end-users to choose which permissions .js and .d.ts files have.

Actual behavior:

TMK, by default tsc writes files that do not have the correct permissions. If tsc creates a directory, sometimes that I do not have permissions to read/write/execute files in that dir, which is very strange.

@ORESoftware ORESoftware changed the title typescript /tsc file permissions appear to be broken typescript / tsc file permissions appear to be broken Jun 21, 2017
@ORESoftware ORESoftware changed the title typescript / tsc file permissions appear to be broken bug: typescript / tsc file permissions appear to be broken Jun 21, 2017
@ORESoftware
Copy link
Author

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jun 21, 2017

I don't really see what a language service plugin has to do with any of this; however, I do agree that file permissions are something we want to get involved with[1]. I'd be willing to hear from others on the team about this though.


[1] Edit: I don't recall what the original intent of this comment was, but I don't actually think this now. What I am still more concerned with is that permissions on directories seems to be broken for certain cases.

@DanielRosenwasser DanielRosenwasser added the Suggestion An idea for TypeScript label Jun 21, 2017
@DanielRosenwasser DanielRosenwasser changed the title bug: typescript / tsc file permissions appear to be broken Allow customizable permissions on emitted files Jun 21, 2017
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jun 21, 2017

By the way, if you don't have permissions on output files, I wonder whether that has to do with TypeScript being installed globally with root (e.g. sudo) privileges.

@ORESoftware
Copy link
Author

ORESoftware commented Jun 21, 2017

@DanielRosenwasser in my case, this doesn't have anything to do with sudo.
I use NVM, and everything is installed in my user home dir. I haven't touched sudo when working with NPM in days. I frankly don't know what is causing the issue, but it's not the first time I have been baffled as to why files and folders generated by TypeScript / tsc do not have the expected permssions.

Expected:
.d.ts and .js files should be readable and executable but not writable.
folders should be readable, writable by the current user.

@ORESoftware
Copy link
Author

ORESoftware commented Jun 21, 2017

So I get this error with git when running a commit

warning: unable to unlink test/src/typescript/@target/a.test.js: Permission denied
warning: unable to unlink test/src/typescript/@target/b.test.js: Permission denied

Here is the tsconfig.json file I have:

{
  "compilerOptions": {
    "declaration": false,
    "outDir": "./@target",
    "baseUrl": ".",
    "paths": {
    },
    "types": [
      "node",
      "async",
      "lodash"
    ],
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": true,
    "removeComments": true,
    "allowUnreachableCode": true,
    "lib": [
      "es2015",
      "es2016",
      "es2017"
    ]
  },
  "include": [
    "./**/*.ts"
  ],
  "exclude": [
    "@target",
    "test",
    "node_modules"
  ]
}

so I am writing all transpiled files to an adjacent directory called @target, and that directory gets written with very restrictive permissions.

@andrew8er
Copy link

This is possibly a broader approach to #16257.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 9, 2017

As noted in #14726 and #16257 this such file permissions modifications are outside the scope of the TS project. you can always add a post build step that sets the permissions on the files as needed.

@mhegazy mhegazy added the Out of Scope This idea sits outside of the TypeScript language design constraints label Nov 9, 2017
@mhegazy mhegazy closed this as completed Nov 9, 2017
@ORESoftware
Copy link
Author

ORESoftware commented Nov 10, 2017

yeah idk about this...do you happen to know if the emitted files have the same exact permissions as the source files? I am not sure I understand what determines the permissions on the target/emitted files.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 10, 2017

The compiler does not do anything with permissions neither reading them from input nor changing them on the output.

@ORESoftware
Copy link
Author

ORESoftware commented Nov 10, 2017

Right so I am confused, what permissions are used then by default when files get written by tsc? Surely someone knows.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants