Browse Source

Adds rudimentary sub-module detection to avoid end-user install when used as a sub-module

pull/1785/head
jlukic 10 years ago
parent
commit
de85e5a82c
2 changed files with 46 additions and 5 deletions
  1. 33
      tasks/config/project/install.js
  2. 18
      tasks/install.js

33
tasks/config/project/install.js

@ -117,6 +117,38 @@ module.exports = {
return walk(directory);
},
// checks if files is PMed submodule
isSubModule: function(directory) {
var
moduleFolders = 0,
walk = function(directory) {
var
pathArray = directory.split('/'),
folder = pathArray[pathArray.length - 2],
nextDirectory = path.normalize(directory + '/../')
;
if( folder == 'bower_components') {
moduleFolders++;
}
else if(folder == 'node_modules') {
moduleFolders++;
}
else if(folder == 'composer') {
moduleFolders++;
}
if(path.resolve(directory) == '/') {
return (moduleFolders > 1);
}
// recurse downward
return walk(nextDirectory);
}
;
// start walk from current directory if none specified
directory = directory || (__dirname + '/');
return walk(directory);
},
createJSON: function(answers) {
var
json = {
@ -175,6 +207,7 @@ module.exports = {
if(answers.uncompressed) {
json.paths.output.uncompressed = path.normalize(answers.uncompressed + '/');
}
console.log(json);
return json;
},

18
tasks/install.js

@ -68,13 +68,20 @@ module.exports = function () {
manager = {
name : 'NPM',
root : path.normalize(__dirname + '/../')
};*/
};
*/
/*--------------
PM Update
PM Config
---------------*/
// currently only supports NPM
/* Don't do end user config if SUI is a sub-module */
if( install.isSubModule() ) {
console.info('SUI is a sub-module, skipping end-user install');
return;
}
// run update scripts if semantic.json exists
if(currentConfig && manager.name === 'NPM') {
var
@ -89,6 +96,7 @@ module.exports = function () {
}
;
// duck-type if there is a project installed
if( fs.existsSync(updatePaths.definition) ) {
@ -337,13 +345,13 @@ module.exports = function () {
;
}
// omit cleanup questions for NPM install
// omit cleanup questions for managed install
if(installFolder) {
questions.cleanup = [];
}
console.log('');
console.log('');
}))
.pipe(prompt.prompt(questions.cleanup, function(answers) {
if(answers.cleanup == 'yes') {

Loading…
Cancel
Save