From 8bb6ac528b43d7c69f12b7e98fd6a04e3d3ae2b6 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Thu, 10 Aug 2023 12:12:18 +0100 Subject: [PATCH] refactor(build): Simplify implementation of posixPath --- scripts/helpers.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/scripts/helpers.js b/scripts/helpers.js index 8dd013835..6346014da 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -11,23 +11,16 @@ const path = require('path'); -/** - * Escape regular expression pattern - * @param {string} pattern regular expression pattern - * @return {string} escaped regular expression pattern - */ -function escapeRegex(pattern) { - return pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); -} - /** * Replaces OS-specific path with POSIX style path. + * Simplified implementation based on + * https://stackoverflow.com/a/63251716/4969945 + * * @param {string} target target path * @return {string} posix path */ function posixPath(target) { - const osSpecificSep = new RegExp(escapeRegex(path.sep), 'g'); - return target.replace(osSpecificSep, path.posix.sep); + return target.split(path.sep).join(path.posix.sep); } module.exports = {