Skip to content

add --login for shell to support directly run from xcode #54

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/WebIDLToSwift/IDLParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum IDLParser {
let pipe = Pipe()
task.standardOutput = pipe
task.standardError = FileHandle.standardError
task.arguments = ["-c", "npm start --silent \(modules.joined(separator: " "))"]
task.arguments = ["--login", "-c", "npm start --silent \(modules.joined(separator: " "))"]
task.launchPath = "/bin/zsh"
task.currentDirectoryURL = URL(fileURLWithPath: #file)
.deletingLastPathComponent()
Expand Down
2 changes: 1 addition & 1 deletion Sources/WebIDLToSwift/Shell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum Shell {
// print("*** running script: \(script)")
let task = Process()
task.standardError = FileHandle.standardError
task.arguments = ["-c", script]
task.arguments = ["--login", "-c", script]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need shell here just to run npm scripts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If without this, the Xcode report can't find swiftformat. Same with the npm start.

Copy link
Member

@kateinoigakukun kateinoigakukun May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right way to do it is telling PATH env var to Xcode scheme

Copy link
Author

@bestwnh bestwnh May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with environment variables, could you provide the values that need to be set?
And what is the down side of adding --login?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not yours fault but I think using shell here at all is not the right way. For example, what happens when your shell is not zsh but bash.

Copy link
Author

@bestwnh bestwnh May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide some key class or method names that can provide a better solution? I may try to make a PR to improve it.

task.launchPath = "/bin/zsh"
task.currentDirectoryURL = projectRoot
task.launch()
Expand Down