-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuel.js
66 lines (47 loc) · 1.46 KB
/
fuel.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
/*
* Project folder structure
*
* - config.json (Contains build information)
* - app.js (Sets up our application namespace and any global settings)
* - main.js (This initaliazes the application)
* - models/ (Contains our application models)
* - templates/ (Contains our application templates)
* - modules/ (Contains modules that are contained blocks of functionality)
* - MODULE_NAME/
* - models/ (Module specific models)
*
*/
var fs = require('fs');
var http = require('http');
var url = require('url');
var args = process.argv.slice(2);
var path = '.';
var server = require('./lib/server');
var ACCEPT_EXT = /(\.js|html|handlebars)$/;
if (args[0] === 'build') {
build(path);
}
if (args[0] === 'server') {
server();
}
// Fuel constructor function
function Fuel (path, config) {
this.path = path;
this.config = config || this._getConfig(path);
}
// Prototype shortcut
Fuel.p = Fuel.prototype;
// Build will take an application path and build any
// assets it finds at the location and output the files
// to the build diretory
Fuel.p.build = function (path, cb) {
this.buildDirectory(path, cb);
}
// Given a path it will build any files at the location based on its config
// It will output files in this order:
// - setup.js - Setup application namespace (Optional for sub-modules)
// - dirs/ - Run through each directory building it
// - init.js - Initializes the app/sub-module
module.exports = function (path, options) {
return new Fuel(path, options);
};