UNPKG

893 BJavaScriptView Raw
1/*jshint node: true*/
2/*eslint-env node*/
3"use strict";
4
5// allows require("gpf-js/source")
6
7const
8 path = require("path"),
9 fs = require("fs"),
10 gpfSourcesPath = path.join(__dirname, "../../../gpf-js/src"),
11 backupOfGpfSourcePath = global.gpfSourcesPath,
12 backupOfGpf = global.gpf,
13
14 restoreGlobal = (name, value) => {
15 if (undefined === value) {
16 delete global[name];
17 } else {
18 global[name] = value;
19 }
20 };
21
22let
23 stats;
24
25try {
26 stats = fs.statSync(gpfSourcesPath);
27} catch (e) {}
28
29if (stats && stats.isDirectory()) {
30 global.gpfSourcesPath = gpfSourcesPath;
31 console.log(gpfSourcesPath);
32 require(gpfSourcesPath + "/boot.js");
33 restoreGlobal("gpfSourcesPath", backupOfGpfSourcePath);
34 module.exports = gpf;
35 restoreGlobal("gpf", backupOfGpf);
36} else {
37 module.exports = require("./build/gpf.js");
38}