1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00
joplin/packages/utils/commandToString.ts
2023-03-19 17:03:04 +00:00

17 lines
390 B
TypeScript

const quotePath = (path: string) => {
if (!path) return '';
if (path.indexOf('"') < 0 && path.indexOf(' ') < 0) return path;
path = path.replace(/"/, '\\"');
return `"${path}"`;
};
export default (commandName: string, args: string[] = []) => {
const output = [quotePath(commandName)];
for (const arg of args) {
output.push(quotePath(arg));
}
return output.join(' ').trim();
};