const fs = require('fs'),
path = require('path');
var CONFIG_ORIGINAL_NAME="config_original.xml"
var CONFIG_FILE_NAME="config.xml"
module.exports = function(context) {
linkViperaCli();
var fsx = undefined;
try{
fsx = context.requireCordovaModule('vipera-de-cli').fsx;
} catch(ex) {
fsx = require('vipera-de-cli').fsx;
}
console.log("begin after prepare variant hook");
var projectRoot = context.opts.projectRoot;
if(fs.existsSync(projectRoot + "/" + CONFIG_ORIGINAL_NAME)){
console.log("Restore default after variant apply");
fsx.copySync(projectRoot + "/" + CONFIG_ORIGINAL_NAME,projectRoot + "/" +CONFIG_FILE_NAME);
fsx.removeSync(projectRoot + "/" + CONFIG_ORIGINAL_NAME);
}
function linkViperaCli(){
try{
require('child_process').execSync(
'npm link vipera-de-cli'
);
}catch(ex){
console.warn("linkViperaCli fail");
}
}
}