mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-26 20:46:17 +00:00
projects reloader is plugin now
This commit is contained in:
parent
4332c50bfc
commit
337e681d4f
2
app.js
2
app.js
@ -234,8 +234,6 @@ Steppy(
|
|||||||
|
|
||||||
notifier.init(app.config.notify, this.slot());
|
notifier.init(app.config.notify, this.slot());
|
||||||
|
|
||||||
require('./projectsWatcher').init(app, this.slot());
|
|
||||||
|
|
||||||
// init resources
|
// init resources
|
||||||
require('./resources')(app);
|
require('./resources')(app);
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
# plugins:
|
plugins:
|
||||||
|
- nci-projects-reloader
|
||||||
# - nci-mail-notification
|
# - nci-mail-notification
|
||||||
# - nci-jabber-notification
|
# - nci-jabber-notification
|
||||||
# - nci-scheduler
|
# - nci-scheduler
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/node-ci/nci",
|
"homepage": "https://github.com/node-ci/nci",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": "1.0.3",
|
|
||||||
"colors": "1.1.2",
|
"colors": "1.1.2",
|
||||||
"data.io": "0.3.0",
|
"data.io": "0.3.0",
|
||||||
"nlevel": "1.0.3",
|
"nlevel": "1.0.3",
|
||||||
@ -68,6 +67,7 @@
|
|||||||
"main-bower-files": "2.7.0",
|
"main-bower-files": "2.7.0",
|
||||||
"memdown": "1.1.0",
|
"memdown": "1.1.0",
|
||||||
"mocha": "1.18.2",
|
"mocha": "1.18.2",
|
||||||
|
"nci-projects-reloader": "0.1.1",
|
||||||
"nci-yaml-reader": "0.1.0",
|
"nci-yaml-reader": "0.1.0",
|
||||||
"nodemon": "1.3.7",
|
"nodemon": "1.3.7",
|
||||||
"nrun": "0.1.4",
|
"nrun": "0.1.4",
|
||||||
|
@ -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();
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user