diff --git a/app.js b/app.js index 2e3f143..4579d0c 100644 --- a/app.js +++ b/app.js @@ -234,8 +234,6 @@ Steppy( notifier.init(app.config.notify, this.slot()); - require('./projectsWatcher').init(app, this.slot()); - // init resources require('./resources')(app); }, diff --git a/data/config.yaml b/data/config.yaml index 1700166..4d839af 100644 --- a/data/config.yaml +++ b/data/config.yaml @@ -1,5 +1,6 @@ -# plugins: +plugins: + - nci-projects-reloader # - nci-mail-notification # - nci-jabber-notification # - nci-scheduler diff --git a/package.json b/package.json index 50004ce..80973b1 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ }, "homepage": "https://github.com/node-ci/nci", "dependencies": { - "chokidar": "1.0.3", "colors": "1.1.2", "data.io": "0.3.0", "nlevel": "1.0.3", @@ -68,6 +67,7 @@ "main-bower-files": "2.7.0", "memdown": "1.1.0", "mocha": "1.18.2", + "nci-projects-reloader": "0.1.1", "nci-yaml-reader": "0.1.0", "nodemon": "1.3.7", "nrun": "0.1.4", diff --git a/projectsWatcher.js b/projectsWatcher.js deleted file mode 100644 index 77aa1a7..0000000 --- a/projectsWatcher.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -var _ = require('underscore'), - path = require('path'), - chokidar = require('chokidar'); - -exports.init = function(app, callback) { - var logger = app.lib.logger('projects watcher'); - - // start file watcher for reloading projects on change - var syncProject = function(filename, fileInfo) { - var projectName = path.relative( - app.config.paths.projects, - path.dirname(filename) - ); - - if (app.projects.get(projectName)) { - logger.log('Unload project: "' + projectName + '"'); - app.projects.unload(projectName); - } - - // on add or change (info is falsy on unlink) - if (fileInfo) { - logger.log('Load project "' + projectName + '" on change'); - app.projects.load(projectName, function(err) { - if (err) { - return logger.error( - 'Error during load project "' + projectName + '": ', - err.stack || err - ); - } - logger.log( - 'Project "' + projectName + '" loaded:', - JSON.stringify(app.projects.get(projectName), null, 4) - ); - }); - } - }; - - // NOTE: currently after add remove and then add same file events will - // not be emitted - var watcher = chokidar.watch( - path.join(app.config.paths.projects, '*', 'config.*'), - {ignoreInitial: true, depth: 1} - ); - watcher.on('add', syncProject); - watcher.on('change', syncProject); - watcher.on('unlink', syncProject); - - watcher.on('error', function(err) { - logger.error('File watcher error occurred: ', err.stack || err); - }); - - callback(); -};