@homeofthings/node-utils
Version:
HomeOfThings - Node Utils: various utilities and common types
17 lines • 497 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.quoteArg = quoteArg;
exports.quoteArgs = quoteArgs;
function quoteArg(arg) {
if (arg.length > 0 && !/[^\w\d%+-./:=@_§€]/.test(arg)) {
return arg;
}
if (!/'/.test(arg)) {
return `'` + arg + `'`;
}
return `"` + arg.replace(/(["\\$`!])/g, '\\$1') + `"`;
}
function quoteArgs(...args) {
return args.map((arg) => quoteArg(arg)).join(' ');
}
//# sourceMappingURL=quote.js.map