tasks/multimocksGenerator.js
function () {
    config.multipleFiles = config.multipleFiles || false;

    var defaultTemplate = singleFileDefaultTemplate;
    if (config.multipleFiles) {
      defaultTemplate = multipleFilesDefaultTemplate;
    }
    config.template = config.template || defaultTemplate;

    var mockSrc = _.isArray(config.src) ? _.first(config.src) : config.src;
    logger('mock source', mockSrc);
    logger('dest', config.dest);
    logger('template', config.template);
    logger('multipleFiles', config.multipleFiles);
    logger('plugins', config.plugins);

    // read all scenario data from manifest/JSON files
    var scenarioData = readScenarioData(config, mockSrc);

    logger('scenarioData', scenarioData);

    var scenarioModuleFilename = config.dest,
      scenarioString;

    if (!config.multipleFiles) {
      // stringify all scenario files into a single Angular module
      scenarioString = JSON.stringify(scenarioData);
      writeScenarioModule(config.template, scenarioModuleFilename,
        scenarioString);
    } else {
      fs.mkdirSync(config.dest);

      // stringify each scenario file into it's own Angular module
      for (var scenarioName in scenarioData) {
        if (scenarioData.hasOwnProperty(scenarioName)) {
          scenarioModuleFilename = config.dest + '/' + scenarioName +
            '.js';

          scenarioString = JSON.stringify(scenarioData[scenarioName]);
          writeScenarioModule(config.template, scenarioModuleFilename,
            scenarioString, scenarioName);
        }
      }
    }
  }
function () {
    config.multipleFiles = config.multipleFiles || false;

    var defaultTemplate = singleFileDefaultTemplate;
    if (config.multipleFiles) {
      defaultTemplate = multipleFilesDefaultTemplate;
    }
    config.template = config.template || defaultTemplate;

    var mockSrc = _.isArray(config.src) ? _.first(config.src) : config.src;
    logger('mock source', mockSrc);
    logger('dest', config.dest);
    logger('template', config.template);
    logger('multipleFiles', config.multipleFiles);
    logger('plugins', config.plugins);

    // read all scenario data from manifest/JSON files
    var scenarioData = readScenarioData(config, mockSrc);

    logger('scenarioData', scenarioData);

    var scenarioModuleFilename = config.dest,
      scenarioString;

    if (!config.multipleFiles) {
      // stringify all scenario files into a single Angular module
      scenarioString = JSON.stringify(scenarioData);
      writeScenarioModule(config.template, scenarioModuleFilename,
        scenarioString);
    } else {
      fs.mkdirSync(config.dest);

      // stringify each scenario file into it's own Angular module
      for (var scenarioName in scenarioData) {
        if (scenarioData.hasOwnProperty(scenarioName)) {
          scenarioModuleFilename = config.dest + '/' + scenarioName +
            '.js';

          scenarioString = JSON.stringify(scenarioData[scenarioName]);
          writeScenarioModule(config.template, scenarioModuleFilename,
            scenarioString, scenarioName);
        }
      }
    }
  }
function ( ) { config . multipleFiles = config . multipleFiles || false ; var defaultTemplate = singleFileDefaultTemplate ; if ( config . multipleFiles ) { defaultTemplate = multipleFilesDefaultTemplate ; } config . template = config . template || defaultTemplate ; var mockSrc = _ . isArray ( config . src ) ? _ . first ( config . src ) : config . src ; logger ( 'mock source' , mockSrc ) ; logger ( 'dest' , config . dest ) ; logger ( 'template' , config . template ) ; logger ( 'multipleFiles' , config . multipleFiles ) ; logger ( 'plugins' , config . plugins ) ; // read all scenario data from manifest/JSON files var scenarioData = readScenarioData ( config , mockSrc ) ; logger ( 'scenarioData' , scenarioData ) ; var scenarioModuleFilename = config . dest , scenarioString ; if ( ! config . multipleFiles ) { // stringify all scenario files into a single Angular module scenarioString = JSON . stringify ( scenarioData ) ; writeScenarioModule ( config . template , scenarioModuleFilename , scenarioString ) ; } else { fs . mkdirSync ( config . dest ) ; // stringify each scenario file into it's own Angular module for ( var scenarioName in scenarioData ) { if ( scenarioData . hasOwnProperty ( scenarioName ) ) { scenarioModuleFilename = config . dest + '/' + scenarioName + '.js' ; scenarioString = JSON . stringify ( scenarioData [ scenarioName ] ) ; writeScenarioModule ( config . template , scenarioModuleFilename , scenarioString , scenarioName ) ; } } } }
Read mock manifest and JSON files and compile into JS files ready for
inclusion into an Angular app.
Read mock manifest and JSON files and compile into JS files ready for inclusion into an Angular app .