1 | "use strict";
|
2 | var __extends = (this && this.__extends) || function (d, b) {
|
3 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
4 | function __() { this.constructor = d; }
|
5 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6 | };
|
7 | var node_watch = require('node-watch');
|
8 | var nest_1 = require('./nest');
|
9 | var fileJob_1 = require('./../job/fileJob');
|
10 | var fs = require('fs');
|
11 | var path_mod = require('path');
|
12 | var Folder = (function (_super) {
|
13 | __extends(Folder, _super);
|
14 | function Folder(e, path) {
|
15 | var nest_name = path_mod.basename(path);
|
16 | _super.call(this, e, nest_name);
|
17 | this.path = path;
|
18 | }
|
19 | Folder.prototype.load = function () {
|
20 | var fl = this;
|
21 | fs.readdir(fl.path, function (err, items) {
|
22 | items = items.filter(function (item) { return !(/(^|\/)\.[^\/\.]/g).test(item); });
|
23 | items.forEach(function (filename) {
|
24 |
|
25 | var job = new fileJob_1.FileJob(fl.e, fl.path + "/" + filename);
|
26 |
|
27 | fl.arrive(job);
|
28 | });
|
29 | });
|
30 | };
|
31 | Folder.prototype.watch = function () {
|
32 | var fl = this;
|
33 | node_watch(fl.path, function (filename) {
|
34 |
|
35 | var job = new fileJob_1.FileJob(fl.e, fl.path + "/" + filename);
|
36 |
|
37 | fl.arrive(job);
|
38 | });
|
39 | };
|
40 | Folder.prototype.arrive = function (job) {
|
41 | _super.prototype.arrive.call(this, job);
|
42 | };
|
43 | return Folder;
|
44 | }(nest_1.Nest));
|
45 | exports.Folder = Folder;
|