forked from theintern/intern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
66 lines (59 loc) · 1.85 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*jshint node:true */
if (typeof process !== 'undefined' && typeof define === 'undefined') {
(function () {
var internConfig = this.__internConfig = {
baseUrl: process.cwd(),
packages: [
{ name: 'intern', location: __dirname }
],
map: {
intern: {
dojo: 'intern/node_modules/dojo',
chai: 'intern/node_modules/chai/chai'
},
'*': {
'intern/dojo': 'intern/node_modules/dojo'
}
}
};
require('dojo/dojo')(internConfig, [ 'intern/client' ]);
})();
}
else {
define([
'./main',
'./lib/args',
'./lib/util',
'require'
], function (main, args, util, parentRequire) {
if (!args.config) {
throw new Error('Missing "config" argument');
}
if (/^(?:\w+:)?\/\//.test(args.config)) {
throw new Error('Cross-origin loading of configuration data is not allowed for security reasons');
}
main.mode = 'client';
require([ args.config ], function (config) {
util.swapLoader(config.useLoader).then(function (require) {
if (!config.loader) {
config.loader = {};
}
// if a `baseUrl` is specified in the arguments for the page, it should have priority over what came
// from the configuration file. this is especially important for the runner proxy, which serves
// `baseUrl` as the root path and so `baseUrl` must become `/` in the client even if it was something
// else in the config originally (for the server-side loader)
if (args.baseUrl) {
config.loader.baseUrl = args.baseUrl;
}
// Most loaders expose `require.config` for configuration, but the Dojo 1 loader does not
(require.config || require)(this.__internConfig);
(require.config || require)(config.loader);
require([ parentRequire.toAbsMid('./lib/realClient') ], function (realClient) {
realClient.run(args, config);
});
}, function (error) {
console.error(error);
});
});
});
}