var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.taskRnvUnlink=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 _unlinkPackage=function _unlinkPackage(c,key){
var rnvPath=_path.default.join(c.paths.project.nodeModulesDir,key);
var rnvPathUnlinked=_path.default.join(c.paths.project.nodeModulesDir,key+"_unlinked");

if(!(0,_fileutils.fsExistsSync)(rnvPathUnlinked)){
(0,_logger.logInfo)(key+" is not linked. SKIPPING");
}else if((0,_fileutils.fsExistsSync)(rnvPath)){
if((0,_fileutils.fsLstatSync)(rnvPath).isSymbolicLink()){
(0,_fileutils.fsUnlinkSync)(rnvPath);
(0,_fileutils.fsRenameSync)(rnvPathUnlinked,rnvPath);
(0,_logger.logSuccess)(key+" => unlink => SUCCESS");
}else{
(0,_logger.logInfo)(key+" is not a symlink anymore. SKIPPING");
}
}
};


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

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

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


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