- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.5k
          process: argv1 property to preserve original argv[1]
          #49918
        
          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
base: main
Are you sure you want to change the base?
Conversation
| Review requested: 
 | 
257fbfe    to
    d9cf132      
    Compare
  
    d9cf132    to
    75cd731      
    Compare
  
    Co-authored-by: Antoine du Hamel <[email protected]>
| Thinking about the overall concept, I think it would probably make more sense to introduce something like  | 
Co-authored-by: Antoine du Hamel <[email protected]>
| 
 Maybe we can do both? It feels wrong to have  | 
| I don't think we really need  | 
| Whatever what name we decide to go with, it'd be very useful to find a way to expose the info to loader thread. | 
| 
 So it’s the new value of  | 
| I'd rather not create a  We should be explicit about what we're exposing and why so I feel it should have a better name and, yes, resolving first is probably ideal, for consistency. | 
| 
 It exists because  I don’t know what the use cases are for having the input before it gets resolved, and that’s a good argument for not needing  | 
| Yes, I'm aware of what  | 
| I opened this PR because I was surprised to see that we had  If we want to add additional properties like  | 
| I don't think having  | 
| 
 Because Node doesn’t reassign  
 Agreed! But what we have is  | 
Following up #49869, supporting #49432, this PR creates a new
process.argv1property similar toprocess.argv0.Just as
process.argv0preserves the original value ofargv[0]before Node replaces it with the absolute path to the executable,process.argv1preserves the original value ofargv[1]before Node replaces it with the absolute path to the entry point.There are also some refactors to how some of the “pre-execution” functions interact. I refactored options objects into parameters, as I’m told that generally parameters are faster; and the post-replacement
argv[1]is returned to the caller, rather than the caller relying on theprocess.argv[1]global. I also added some JSDoc and comments. @nodejs/startup