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

feat: use getShellStartCommand to get the default command #128

Closed
wants to merge 9 commits into from

Conversation

aminya
Copy link
Contributor

@aminya aminya commented Jul 26, 2020

On Windows, as the default value for the config, this uses pwsh (PowerShellCore) if available on a system. If not it will use powershell, and in the end, it will use cmd.

@the-j0k3r
Copy link
Member

This looks good except for missing updated tests otherwise 👍

@the-j0k3r the-j0k3r requested a review from UziTech July 27, 2020 08:19
@the-j0k3r the-j0k3r self-requested a review July 27, 2020 09:43
src/utils.js Outdated Show resolved Hide resolved
src/utils.js Outdated Show resolved Hide resolved
@aminya
Copy link
Contributor Author

aminya commented Jul 27, 2020

I added a sync version using which which is faster. Then I used a trick to work around Atom not supporting async config reading and made the config setting async.

@UziTech
Copy link
Member

UziTech commented Jul 27, 2020

I added a sync version using which which is faster.

My tests show that if the user doesn't have powershell or pwsh it took my computer 320-380 ms to get the defaults. Without this PR it took 0.18 - 0.32 ms

I'm thinking that ~300ms is not worth the more accurate default.

If you can get Atom to load the config asynchronously it might be worth it.

@aminya

This comment has been minimized.

@aminya
Copy link
Contributor Author

aminya commented Jul 27, 2020

@UziTech For the tests, could you make which function work the same way you faked childProcess?

src/utils.js Outdated Show resolved Hide resolved
@UziTech
Copy link
Member

UziTech commented Jul 28, 2020

@UziTech For the tests, could you make which function work the same way you faked childProcess?

You can only mock properties and methods of an object. If you want to mock an imported function you will have to inject a spy some how.

something like:

async function getShellStartCommand (find = which) {
  ...
  find('pwsh')
  ...
}
...
it('test', () => {
  const spy = jasmine.createSpy('which')
  getShellStartCommand(spy)
  ...
})

src/config.js Outdated Show resolved Hide resolved
@aminya
Copy link
Contributor Author

aminya commented Aug 5, 2020

This only needs the tests. If you can help with that, I would appreciate it.

Comment on lines +580 to +582
atom.config.observe('x-terminal.spawnPtySettings.command', () => {
atom.config.set('x-terminal.spawnPtySettings.autoCommand', false)
}),
Copy link
Member

Choose a reason for hiding this comment

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

Should we also observe autoCommand and reset command if it is checked?

type: 'boolean',
default: configDefaults.autoCommand,
profileData: {
defaultProfile: configDefaults.command,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
defaultProfile: configDefaults.command,
defaultProfile: configDefaults.autoCommand,

@github-actions
Copy link

github-actions bot commented Oct 7, 2020

🎉 This issue has been resolved in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released 📮 Release has been made label Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released 📮 Release has been made
Development

Successfully merging this pull request may close these issues.

3 participants