From 9b29dddea6be614db4d4823f4afc3fbf58738cb4 Mon Sep 17 00:00:00 2001 From: Cody Balos Date: Sat, 15 Oct 2016 12:37:57 -0700 Subject: [PATCH] Add support for git submodules. Addresses issue #54. --- lib/command-requirements.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/command-requirements.js b/lib/command-requirements.js index 9d2b7b0..2365773 100644 --- a/lib/command-requirements.js +++ b/lib/command-requirements.js @@ -1,4 +1,5 @@ -var fs = require('fs'); +var fs = require('fs'), + path = require('path'); module.exports = { git: function(req) { @@ -8,9 +9,22 @@ module.exports = { if (stat.isDirectory()) { return true; } - } catch (e) { } + } catch (e) { + // check if the directory is a submodule + // addresses https://github.com/mixu/gr/issues/54 + if (e.code === 'ENOTDIR' || e.code === 'ENOENT') + { + var parentPath = path.dirname(req.path); + try { + stat = fs.statSync(parentPath + '/.gitmodules'); + if (stat.isFile()) { + return true; + } + } catch (e) { } + } + } if (req.format === 'human') { - console.log('Skipped ' + req.path + ' as it does not have a .git subdirectory.'); + console.log('Skipped ' + req.path + ' as it does not have a .git subdirectory and is not a submodule.'); } return false; }, @@ -19,10 +33,10 @@ module.exports = { try { stat = fs.statSync(req.path + '/Makefile'); if (stat.isFile()) { - return true; } } catch (e) { } if (req.format === 'human') { + return true; console.log('Skipped ' + req.path + ' as it does not have a ./Makefile file.'); } return false;