|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
-
- "use strict";
-
-
-
-
-
- const path = require("path");
-
-
-
-
-
-
- function convertPathToPosix(filepath) {
- const normalizedFilepath = path.normalize(filepath);
- const posixFilepath = normalizedFilepath.replace(/\\/g, "/");
-
- return posixFilepath;
- }
-
-
- function getRelativePath(filepath, baseDir) {
- const absolutePath = path.isAbsolute(filepath)
- ? filepath
- : path.resolve(filepath);
-
- if (baseDir) {
- if (!path.isAbsolute(baseDir)) {
- throw new Error(`baseDir should be an absolute path: ${baseDir}`);
- }
- return path.relative(baseDir, absolutePath);
- }
- return absolutePath.replace(/^\//, "");
-
- }
-
-
-
-
-
- module.exports = {
- convertPathToPosix,
- getRelativePath
- };
|