1 | const { sep, normalize } = require("path");
|
2 |
|
3 | function cleanPath(dirPath) {
|
4 | let normalized = normalize(dirPath);
|
5 |
|
6 | // to account for / path
|
7 | if (normalized.length > 1 && normalized[normalized.length - 1] === sep)
|
8 | normalized = normalized.substring(0, normalized.length - 1);
|
9 | return normalized;
|
10 | }
|
11 |
|
12 | module.exports = { cleanPath };
|