如何将一个对象从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
作为输出。
- 在使用Inkscape在gulp任务中使用SVG时遇到问题
- SyntaxError:意外的严格模式保留字
- 吞噬和注入path
- 导入关键字不被gulp throwing识别SyntaxError:意外的保留字
- browserSync的modRewrite不适用于angularjs html5mode的path“app / index.html”与吞咽
- 当我inputnpm start时如何开始Gulp监视任务
- Node.js:我如何将全局variables传递给通过require()插入的文件?
- 使用Gulp.js和globbing模式修改文件(相同的目标)
- ES 2015 VS 2015 for node.js运行任务运行器资源pipe理器