-
Notifications
You must be signed in to change notification settings - Fork 79
test(editor): use a node script as an external editor MONGOSH-992 #1118
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
Conversation
@addaleax Thx a lot for taking a look so quickly ❤️ |
fb83766
to
cf04e0a
Compare
packages/editor/src/editor.spec.ts
Outdated
const tmpDoc = process.argv[process.argv.length - 1]; | ||
const { promises: { writeFile } } = require('fs'); | ||
await writeFile(tmpDoc, \`${output}\`, { mode: 0o600 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
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.
2594d59
to
a75d68f
Compare
25402d6
to
57c0c63
Compare
!(argv[0] ?? '').startsWith('(') | ||
) { | ||
return shellApi[cmd](input); | ||
const code = /^(\S+)$/.test(trimmedInput) ? '' : trimmedInput.replace(/^\S+\s+/, ''); |
There was a problem hiding this comment.
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
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)
Check spawing processes by replacing an external editor with nodejs script.