2

I have an object in my Gulp task which contains the data of my Yaml files. Now I want to access this object from other JavaScript files.

This is what my Gulp Task looks like:

Gulpfile.js

var mergedYaml

gulp.task('LoadYamlFiles', function() {
mergedYaml = global.mergedYaml;
    try {
        //Load all the Yaml files available inside pom folder
        glob("tests/acceptance/wdio/utilities/pom/*.yml", function (er, files) {
            mergedYaml = yamlMerge.mergeFiles(files);
        })
    }
    catch (e){
        console.log(e);
    }
});

exports.mergedYaml = mergedYaml

This is how I am trying to access it:

Test.js

try {


    var mergedYaml = require('../../../../gulpfile.js').mergedYaml;
    console.log(mergedYaml);
}

catch (e){
    console.log(e);
}

Console.log is displaying Undefined as the output.

gariepy
  • 3,576
  • 6
  • 21
  • 34
Sim_8
  • 56
  • 4

0 Answers0