Skip to content

Conversation

alenakhineika
Copy link
Contributor

Check spawing processes by replacing an external editor with nodejs script.

@alenakhineika
Copy link
Contributor Author

alenakhineika commented Sep 24, 2021

@addaleax Thx a lot for taking a look so quickly ❤️

@alenakhineika alenakhineika force-pushed the MONGOSH-992-e2e-tests-for-editor branch from fb83766 to cf04e0a Compare September 29, 2021 16:12
const tmpDoc = process.argv[process.argv.length - 1];
const { promises: { writeFile } } = require('fs');
await writeFile(tmpDoc, \`${output}\`, { mode: 0o600 });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
await writeFile(tmpDoc, \`${output}\`, { mode: 0o600 });
await writeFile(tmpDoc, ${JSON.stringify(output)}, { mode: 0o600 });

So that this doesn’t break if output contains a backtick or escape sequences?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I don't have these cases in my tests, so it doesn't :) If we want to cover such cases in tests I can replace it with JSON.stringify.

@alenakhineika alenakhineika marked this pull request as ready for review September 30, 2021 09:41
@alenakhineika alenakhineika force-pushed the MONGOSH-992-e2e-tests-for-editor branch from 2594d59 to a75d68f Compare September 30, 2021 11:36
@alenakhineika alenakhineika force-pushed the MONGOSH-992-e2e-tests-for-editor branch from 25402d6 to 57c0c63 Compare September 30, 2021 13:53
!(argv[0] ?? '').startsWith('(')
) {
return shellApi[cmd](input);
const code = /^(\S+)$/.test(trimmedInput) ? '' : trimmedInput.replace(/^\S+\s+/, '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the same as

Suggested change
const code = /^(\S+)$/.test(trimmedInput) ? '' : trimmedInput.replace(/^\S+\s+/, '');
const code = trimmedInput.replace(/^\S+\s*/, '');

right?

Also, I wouldn't call this code, it's code when it refers to the edit command but this is fairly generic, I would call it something like rawArgument or rawInput (also because that's consistent with acceptsRawInput elsewhere)

@alenakhineika alenakhineika merged commit 74b2159 into main Oct 1, 2021
@alenakhineika alenakhineika deleted the MONGOSH-992-e2e-tests-for-editor branch October 1, 2021 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants