1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 | const readAnswerSpace = require('./resource').readAnswerSpace;
|
6 | const scope = require('./scope');
|
7 |
|
8 |
|
9 |
|
10 | function validateScopeMatchesContent (options) {
|
11 | return Promise.all([
|
12 | scope.read(),
|
13 | readAnswerSpace(options).catch(() => ({}))
|
14 | ])
|
15 | .then((results) => {
|
16 | const scope = results[0];
|
17 | const space = results[1];
|
18 | if (!space.name) {
|
19 | return;
|
20 | }
|
21 | if (!scope.endsWith(`/${space.name}`)) {
|
22 | throw new Error(`scope-content mismatch: scope=${scope}, name=${space.name}`);
|
23 | }
|
24 | });
|
25 | }
|
26 |
|
27 | module.exports = {
|
28 | validateScopeMatchesContent
|
29 | };
|