如何将一个对象从gulpfile传递到nodejs中的另一个JavaScript文件?
我的Gulp任务中有一个对象,其中包含Yaml文件的数据。现在我想从其他JavaScript文件访问这个对象 这就是我的吞咽任务的样子: Gulpfile.js如何将一个对象从gulpfile传递到nodejs中的另一个JavaScript文件?,javascript,node.js,gulp,yaml,Javascript,Node.js,Gulp,Yaml,我的Gulp任务中有一个对象,其中包含Yaml文件的数据。现在我想从其他JavaScript文件访问这个对象 这就是我的吞咽任务的样子: Gulpfile.js var mergedYaml gulp.task('LoadYamlFiles', function() { mergedYaml = global.mergedYaml; try { //Load all the Yaml files available inside pom folder g
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正在将未定义
显示为输出