v1.18.x
Julian Lam 10 years ago
parent 1069f9c936
commit c6643082e2

@ -183,7 +183,7 @@ function start() {
require('./src/meta').configs.init(next); require('./src/meta').configs.init(next);
}, },
function(next) { function(next) {
return next(new Error('dependencies-out-of-date')); require('./src/meta').dependencies.check(next);
}, },
function(next) { function(next) {
require('./src/upgrade').check(next); require('./src/upgrade').check(next);

@ -24,6 +24,7 @@ var async = require('async'),
require('./meta/settings')(Meta); require('./meta/settings')(Meta);
require('./meta/logs')(Meta); require('./meta/logs')(Meta);
require('./meta/tags')(Meta); require('./meta/tags')(Meta);
require('./meta/dependencies')(Meta);
Meta.templates = require('./meta/templates'); Meta.templates = require('./meta/templates');
/* Assorted */ /* Assorted */

@ -0,0 +1,41 @@
'use strict';
var path = require('path'),
fs = require('fs'),
async = require('async'),
semver = require('semver'),
winston = require('winston'),
pkg = require.main.require('./package.json');
module.exports = function(Meta) {
Meta.dependencies = {};
Meta.dependencies.check = function(callback) {
var modules = Object.keys(pkg.dependencies);
winston.verbose('Checking dependencies for outdated modules');
async.every(modules, function(module, next) {
fs.readFile(path.join(__dirname, '../../node_modules/', module, 'package.json'), {
encoding: 'utf-8'
}, function(err, pkgData) {
try {
var pkgData = JSON.parse(pkgData),
ok = semver.satisfies(pkgData.version, pkg.dependencies[module]);
if (ok) {
next(true);
} else {
process.stdout.write('[' + 'outdated'.yellow + '] ' + module.bold + ' v' + pkgData.version + ', requires ' + pkg.dependencies[module] + '\n')
next(false);
}
} catch(e) {
winston.error('[meta.dependencies] Could not read: ' + module);
process.exit();
}
})
}, function(ok) {
callback(!ok ? new Error('dependencies-out-of-date') : null);
});
};
};
Loading…
Cancel
Save