var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _path=_interopRequireDefault(require("path"));
var _fs=_interopRequireDefault(require("fs"));
var _common=require("../common");
var _fileutils=require("../systemTools/fileutils");

var LINK='link';





var run=function run(c){
(0,_common.logTask)('run');

switch(c.command){
case LINK:
return _link(c);
default:
return Promise.reject("cli:linker: Command "+c.command+" not supported");}

};





var _link=function _link(c){return new Promise(function(resolve){
if(_fs.default.existsSync(c.paths.project.npmLinkPolyfill)){
var l=JSON.parse(_fs.default.readFileSync(c.paths.project.npmLinkPolyfill).toString());
Object.keys(l).forEach(function(key){

var source=_path.default.resolve(l[key]);
var nm=_path.default.join(source,'node_modules');
var dest=_path.default.join(c.paths.project.nodeModulesDir,key);
if(_fs.default.existsSync(source)){
(0,_fileutils.copyFolderContentsRecursiveSync)(source,dest,false,[nm]);
}else{
(0,_common.logWarning)("Source: "+source+" doesn't exists!");
}
});
}else{
(0,_common.logWarning)(c.paths.project.npmLinkPolyfill+" file not found. nothing to link!");
resolve();
}
});};var _default=

run;exports.default=_default;
//# sourceMappingURL=linker.js.map