"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.installDependency=installDependency;exports.default=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _child_process=_interopRequireDefault(require("child_process"));

var _corenode=require("corenode");
var _utils=require("@corenode/utils");function

installDependency(_x){return _installDependency.apply(this,arguments)}function _installDependency(){_installDependency=(0,_asyncToGenerator2.default)(function*({params,caller}){


return new Promise((resolve,reject)=>{
const localpackage=(0,_corenode.getRootPackage)();
if(typeof localpackage.dependencies!=="undefined"){
if(localpackage.dependencies[`${params.pkg}`]){
_utils.verbosity.log(`${params.pkg} is already installed > ${localpackage.dependencies[`${params.pkg}`]}`);
return resolve(true);
}
}

_utils.verbosity.log(`Installing from npm > ${params.pkg} < Requested by (${caller})`);

const npmi=_child_process.default.exec(`npm install --quiet --no-progress --silent ${params.pkg}`,{},(error,stdout,stderr)=>{
if(stdout){
_utils.verbosity.log(stdout);
}
if(error){
_utils.verbosity.log(stdout);
return reject(error);
}
});

npmi.on("exit",code=>{
return resolve(code);
});
});
});return _installDependency.apply(this,arguments)}var _default=

installDependency;exports.default=_default;