@nxworker/workspace
Version:
Nx plugin providing generators for managing workspace files, including the move-file generator for safely moving files between projects while updating all imports
28 lines (27 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getRelativeImportSpecifier", {
enumerable: true,
get: function() {
return getRelativeImportSpecifier;
}
});
const _devkit = require("@nx/devkit");
const _nodepath = require("node:path");
const _toabsoluteworkspacepath = require("./to-absolute-workspace-path");
const _stripfileextension = require("./strip-file-extension");
function getRelativeImportSpecifier(fromFilePath, toFilePath) {
const normalizedFrom = (0, _devkit.normalizePath)(fromFilePath);
const normalizedTo = (0, _devkit.normalizePath)(toFilePath);
const absoluteFromDir = _nodepath.posix.dirname((0, _toabsoluteworkspacepath.toAbsoluteWorkspacePath)(normalizedFrom));
const absoluteTarget = (0, _toabsoluteworkspacepath.toAbsoluteWorkspacePath)(normalizedTo);
let relativePath = _nodepath.posix.relative(absoluteFromDir, absoluteTarget);
if (!relativePath.startsWith('.')) {
relativePath = `./${relativePath}`;
}
relativePath = (0, _devkit.normalizePath)(relativePath);
return (0, _stripfileextension.stripFileExtension)(relativePath);
}
//# sourceMappingURL=get-relative-import-specifier.js.map