UNPKG

917 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _normalizePattern2;
8
9function _load_normalizePattern() {
10 return _normalizePattern2 = require('./util/normalize-pattern.js');
11}
12
13const semver = require('semver');
14
15class WorkspaceLayout {
16 constructor(workspaces, config) {
17 this.workspaces = workspaces;
18 this.config = config;
19 }
20
21 getWorkspaceManifest(key) {
22 return this.workspaces[key];
23 }
24
25 getManifestByPattern(pattern) {
26 var _normalizePattern = (0, (_normalizePattern2 || _load_normalizePattern()).normalizePattern)(pattern);
27
28 const name = _normalizePattern.name,
29 range = _normalizePattern.range;
30
31 const workspace = this.getWorkspaceManifest(name);
32 if (!workspace || !semver.satisfies(workspace.manifest.version, range, this.config.looseSemver)) {
33 return null;
34 }
35 return workspace;
36 }
37}
38exports.default = WorkspaceLayout;
\No newline at end of file