Fix cylon command issue if no node_modules directory is present
This commit is contained in:
parent
eced9ab6fe
commit
f174386672
12
bin/cylon
12
bin/cylon
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
var program = require('commander'),
|
var program = require('commander'),
|
||||||
pkg = require('../package.json');
|
pkg = require('../package.json'),
|
||||||
|
fs = require('fs');
|
||||||
|
|
||||||
program
|
program
|
||||||
.version(pkg.version)
|
.version(pkg.version)
|
||||||
|
@ -14,8 +15,10 @@ program
|
||||||
|
|
||||||
argv = program.parse(process.argv);
|
argv = program.parse(process.argv);
|
||||||
|
|
||||||
// require all cylon-* modules
|
var modules_path = process.cwd() + '/node_modules/';
|
||||||
require('fs').readdirSync(process.cwd() + '/node_modules/').forEach(function(dir) {
|
if (fs.existsSync(modules_path)) {
|
||||||
|
// require all cylon-* modules
|
||||||
|
fs.readdirSync(modules_path).forEach(function(dir) {
|
||||||
if (dir.match(/^cylon-.*/) !== null) {
|
if (dir.match(/^cylon-.*/) !== null) {
|
||||||
if (typeof require(dir).registerCommands === 'function') {
|
if (typeof require(dir).registerCommands === 'function') {
|
||||||
var commands = require(dir).registerCommands();
|
var commands = require(dir).registerCommands();
|
||||||
|
@ -32,7 +35,8 @@ require('fs').readdirSync(process.cwd() + '/node_modules/').forEach(function(dir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// print help if no arguments were provided
|
// print help if no arguments were provided
|
||||||
if(!program.args.length) { program.help(); }
|
if(!program.args.length) { program.help(); }
|
||||||
|
|
Loading…
Reference in New Issue