Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

vipera-npm-registry / de-core-plugin   js

Repository URL to install this package:

Version: 0.2.0 

/ hook / variant_after_prepare.js

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");
    }
  }
}