1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00
joplin/packages/utils/commandToString.ts

17 lines
390 B
TypeScript
Raw Normal View History

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));
}
2023-03-19 19:03:04 +02:00
return output.join(' ').trim();
};