var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.taskRnvLink=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _path=_interopRequireDefault(require("path"));
var _logger=require("../../core/systemManager/logger");
var _constants=require("../../core/constants");
var _fileutils=require("../../core/systemManager/fileutils");



var _linkPackage=function _linkPackage(c,key,folder){
var rnvPath=_path.default.join(c.paths.project.nodeModulesDir,key);
var rnvPathUnlinked=_path.default.join(c.paths.project.nodeModulesDir,key+"_unlinked");
var pkgDir=_path.default.join(c.paths.rnv.dir,'../',folder);

if((0,_fileutils.fsExistsSync)(rnvPathUnlinked)){
(0,_logger.logInfo)(key+" is already linked. SKIPPING");
}else if((0,_fileutils.fsExistsSync)(rnvPath)){
(0,_fileutils.fsRenameSync)(rnvPath,rnvPathUnlinked);
(0,_fileutils.fsSymlinkSync)(pkgDir,rnvPath);
(0,_logger.logSuccess)(key+" => link => SUCCESS");
}
};

var taskRnvLink=function taskRnvLink(c){return _regenerator.default.async(function taskRnvLink$(_context){while(1){switch(_context.prev=_context.next){case 0:
(0,_logger.logTask)('taskRnvLink');

_constants.RNV_PACKAGES.forEach(function(pkg){
if(!pkg.skipLinking){
_linkPackage(c,pkg.packageName,pkg.folderName);
}
});return _context.abrupt("return",

true);case 3:case"end":return _context.stop();}}},null,null,null,Promise);};exports.taskRnvLink=taskRnvLink;var _default=


{
description:'',
fn:taskRnvLink,
task:'link',
params:_constants.PARAMS.withBase(),
platforms:[],
skipPlatforms:true,
isGlobalScope:true};exports.default=_default;
//# sourceMappingURL=task.rnv.link.js.map