All files / piscosour/steps/add-flows index.js

0% Statements 0/18
0% Branches 0/2
0% Functions 0/2
0% Lines 0/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                                         
'use strict';
 
let path = require('path');
let fs = require('fs');
 
module.exports = {
 
  flow: {},
 
  config: function(resolve) {
    this.logger.info('#magenta', 'config', 'Configuring flow', this.params.flowKey);
 
    this.fsCreateDir('flows');
    this.fsCreateDir(path.join('flows', this.params.flowKey));
 
    var file = path.join('flows', this.params.flowKey, 'config.json');
 
    this.flow = this.fsReadConfig(file, true);
    if (!this.flow.steps) {
      this.flow.steps = {};
      this.inquire('promptsFlow').then(resolve);
      return true;
    }
  },
 
  run: function() {
    this.logger.info('#magenta', 'run', 'Creating/managing flow', this.params.flowKey);
 
    this.flow.name = this.params.flowKey;
    this.flow.description = this.params.flowDescription;
    this.flow.type = 'normal';
 
    var file = path.join('flows', this.params.flowKey, 'config.json');
    fs.writeFileSync(file, JSON.stringify(this.flow, null, 2));
  }
};