Skip to content
This repository has been archived by the owner on Feb 4, 2018. It is now read-only.

Adds a save option to add the installed dependencies to the packages.json of the project. #2

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions bin/gulpfile-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@
var regex = /require\((?:'|")(.*?)(?:'|")\)/g

// Take gulpfile as an argument or use the one in current directory
var gulpfilePath = process.argv[2] || 'gulpfile.js'
var gulpfilePath = 'gulpfile.js'
var save = ""

var save_values = ['-s', '--save-dev']
process.argv.forEach(function(val, index, array) {
var save_index = save_values.indexOf(val)
if (save_index >= 0) {
save = '--save-dev'
}

if(val.match(/gulpfile.js/gi)){
gulpfilePath = val
}
});

require('fs').readFile(gulpfilePath , 'utf8', function(err, data){
var modules = []
Expand All @@ -16,7 +28,7 @@ require('fs').readFile(gulpfilePath , 'utf8', function(err, data){
}

var commands = modules.map(function(command){
return 'npm install ' + command + ';'
return 'npm install ' + command + ' '+ save + ';'
})

console.log('\n\nInstalling modules: \n\t' + modules.join('\n\t') + '\n\n')
Expand Down