1 | var Facade;
|
2 |
|
3 | Facade = require('./lib/facade');
|
4 |
|
5 | Facade.fs = require('fs');
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | Facade.requireFile = function(file) {
|
20 | var fileInfo, path, ret;
|
21 | if (typeof Ti === "undefined" || Ti === null) {
|
22 | ret = require(file);
|
23 | if (ret["default"]) {
|
24 | return ret["default"];
|
25 | } else {
|
26 | return ret;
|
27 | }
|
28 | }
|
29 | path = file + '.js';
|
30 | if (Ti.Platform.name === 'android') {
|
31 | return require(file);
|
32 | }
|
33 | fileInfo = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, path);
|
34 | if (fileInfo.exists()) {
|
35 | return require(file);
|
36 | } else {
|
37 | throw new Error(path + ": no such file.");
|
38 | }
|
39 | };
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | Facade.requireJSON = function(path) {
|
51 | var fileInfo;
|
52 | if (typeof Ti === "undefined" || Ti === null) {
|
53 | return require(path);
|
54 | }
|
55 | fileInfo = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, path);
|
56 | if (fileInfo.exists()) {
|
57 | return JSON.parse(fileInfo.read().getText());
|
58 | } else {
|
59 | throw new Error(path + ": no such file.");
|
60 | }
|
61 | };
|
62 |
|
63 | module.exports = Facade;
|