Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50659 views
1
/*
2
* directories.js: Plugin for creating directories for a required for a broadway App.
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var common = require('../common');
10
11
//
12
// ### Name this plugin
13
//
14
exports.name = 'directories';
15
16
//
17
// ### function attach (options)
18
// #### @options {Object} Options for this plugin
19
// #### @done {function} Continuation to respond to when complete.
20
// Prepopulates the directory structure of `this` (the application).
21
//
22
exports.attach = function (options) {
23
options = options || {};
24
25
if (this.config) {
26
//
27
// Merge options with any pre-existing application config.
28
//
29
options = common.mixin({}, options, this.config.get('directories') || {});
30
}
31
32
options = common.directories.normalize({'#ROOT': this.root}, options);
33
this.options['directories'] = options;
34
35
if (this.config) {
36
this.config.merge('directories', options);
37
}
38
};
39
40
//
41
// ### function init (done)
42
// #### @done {function} Continuation to respond to when complete.
43
// Creates the directories associated with this instance.
44
//
45
exports.init = function (done) {
46
common.directories.create(this.options['directories'], function (err) {
47
return err ? done(err) : done();
48
});
49
};
50
51