UNPKG

632 BJavaScriptView Raw
1'use strict';
2
3// local modules
4
5const readAnswerSpace = require('./resource').readAnswerSpace;
6const scope = require('./scope');
7
8// this module
9
10function 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
27module.exports = {
28 validateScopeMatchesContent
29};