wallet-core/node_modules/webpack/lib/util/identifier.js
2017-05-03 15:35:00 +02:00

17 lines
450 B
JavaScript

"use strict";
const path = require("path");
const looksLikeAbsolutePath = (maybeAbsolutePath) => {
return /^(?:[a-z]:\\|\/)/i.test(maybeAbsolutePath);
};
const normalizePathSeparator = (p) => p.replace(/\\/g, "/");
exports.makePathsRelative = (context, identifier) => {
return identifier
.split(/([|! ])/)
.map(str => looksLikeAbsolutePath(str) ?
normalizePathSeparator(path.relative(context, str)) : str)
.join("");
};