1 | "use strict";
|
2 | var fs = require("fs");
|
3 | exports.introspectionFromFile = function (file) {
|
4 | return new Promise(function (resolve, reject) {
|
5 | if (fs.existsSync(file)) {
|
6 | try {
|
7 | var fileContent = fs.readFileSync(file, 'utf8');
|
8 | if (!fileContent) {
|
9 | reject("Unable to read local introspection file: " + file);
|
10 | }
|
11 | var introspection = JSON.parse(fileContent);
|
12 | if (introspection.data) {
|
13 | introspection = introspection.data;
|
14 | }
|
15 | resolve(introspection);
|
16 | }
|
17 | catch (e) {
|
18 | reject(e);
|
19 | }
|
20 | }
|
21 | else {
|
22 | reject("Unable to locate local introspection file: " + file);
|
23 | }
|
24 | });
|
25 | };
|
26 |
|
\ | No newline at end of file |