-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.js
More file actions
65 lines (49 loc) · 1.54 KB
/
bootstrap.js
File metadata and controls
65 lines (49 loc) · 1.54 KB
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
/**
*
* Bootstrap the project with necessary globals.
*
* @author Salvatore Garbesi <sal@dolox.com>
* @module bootstrap
*
* @return {undefined} Nothing is returned from this Function.
*
**/
module.exports = (function(GLOBAL) {
'use strict';
// Require the Lodash utility.
GLOBAL._ = require('lodash');
// The application namespace.
GLOBAL.app = {};
// The native process handler module.
GLOBAL.childProcess = require('child_process');
// The command utility to help with CLI interaction.
GLOBAL.commander = require('commander');
// Autoload files under a specific namespace.
GLOBAL.expressLoad = require('express-load');
// The native file system module.
GLOBAL.fs = require('fs');
// Generate UUIDs.
GLOBAL.nodeUuid = require('node-uuid');
// The native path module.
GLOBAL.path = require('path');
// Load the `package.json` file.
GLOBAL.pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json')));
// The temporary directory for the project.
GLOBAL.tmp = path.join(__dirname, 'tmp');
// Logging utility.
GLOBAL.winston = require('winston');
// Autoload the source files into memory.
expressLoad('mixin', {
cwd: __dirname
}).then('controller', {
cwd: __dirname
}).into(app);
// Create the temporary directory for the project.
fs.existsSync(tmp) === false ? fs.mkdirSync(tmp) : null;
// Swap the package name for the `cli`.
process.argv[1] = pkg.name;
// Boot the CLI configuration.
GLOBAL.cli = app.controller.cli.boot();
// Generate a new winston instance.
GLOBAL.log = app.controller.log.boot();
}(GLOBAL));