@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
35 lines (34 loc) • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isFileExported", {
enumerable: true,
get: function() {
return isFileExported;
}
});
const _getprojectentrypointpaths = require("../project-analysis/get-project-entry-point-paths");
const _removesourcefileextension = require("../path-utils/remove-source-file-extension");
const _escaperegex = require("../security-utils/escape-regex");
const _treecache = require("../tree-cache");
function isFileExported(tree, project, file, cachedTreeExists) {
const indexPaths = (0, _getprojectentrypointpaths.getProjectEntryPointPaths)(tree, project);
const fileWithoutExt = (0, _removesourcefileextension.removeSourceFileExtension)(file);
const escapedFile = (0, _escaperegex.escapeRegex)(fileWithoutExt);
return indexPaths.some((indexPath)=>{
if (!cachedTreeExists(tree, indexPath)) {
return false;
}
const content = _treecache.treeReadCache.read(tree, indexPath, 'utf-8');
if (!content) {
return false;
}
// Support: export ... from "path"
// Support: export * from "path"
// Support: export { Something } from "path"
const exportPattern = new RegExp(`export\\s+(?:\\*|\\{[^}]+\\}|.+)\\s+from\\s+['"]\\.?\\.?/.*${escapedFile}['"]`);
return exportPattern.test(content);
});
}
//# sourceMappingURL=is-file-exported.js.map