Files
dorny-paths-filter/src/shell-escape.ts
T

7 lines
347 B
TypeScript
Raw Normal View History

2020-08-30 21:18:14 +02:00
// Credits to https://github.com/xxorax/node-shell-escape
export default function shellEscape(value: string): string {
return `'${value.replace(/'/g, "'\\''")}'`
.replace(/^(?:'')+/g, '') // unduplicate single-quote at the beginning
.replace(/\\'''/g, "\\'") // remove non-escaped single-quote if there are enclosed between 2 escaped
}