Skip to content
Prev Previous commit
Next Next commit
wip: defined if/else if in my function
  • Loading branch information
F Adonis committed Jul 15, 2018
commit 4444aa0b315d58d98e96d179919bf05cedf28119
40 changes: 39 additions & 1 deletion lib/mp.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
'use strict'

const FILE_REGEX = /\.[0-9a-z]+$/i;

const mp = (args, cb) => {
console.log('Inside MP');

if(args.length === 0) {

checkFile(displayPackages);

} else if((args.includes('i') && (args.includes('c') || args.includes('check'))) || (args.includes('install') && (args.includes('c') || args.includes('check')))) {

// display usage

} else if (args.includes('i') || args.includes('install')) {

let recursive = (args.includes('r') || args.includes('recursive')) ? true : false;
checkDirectory(process.cwd() + "/" + file, recursive, installPackages);

} else if (args.includes('c') || args.includes('check')) {

let recursive = (args.includes('r') || args.includes('recursive')) ? true : false;
checkDirectory(process.cwd() + "/" + file, recursive, displayPackages);

} else if(args.length === 1 && args[0].match(FILE_REGEX)) {

checkFile(displayPackages, args);

}

// Put callback inside th shit so it doesnt fuck me synchronously
cb();
}





// TODO: MODIFY checkFile and add getPackageJson






module.exports = mp;