如何将一个对象从gulpfile传递给nodejs中的另一个JavaScript文件?
我在我的Gulp任务中有一个对象,其中包含我的Yaml文件的数据。 现在我想从其他JavaScript文件访问这个对象。
这是我的Gulp任务的样子:
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
这是我试图访问它的方式:
Test.js
try { var mergedYaml = require('../../../../gulpfile.js').mergedYaml; console.log(mergedYaml); } catch (e){ console.log(e); }
Console.log显示Undefined
作为输出。