我正在使用$ npm运行index.js
在index.js文件中,我正在循环并获取以下文件的列表,我们需要从该文件中读取“ testData”,请您帮忙获取数据
/test/file_1.js
/test/file_2.js
每个文件都有
/test/file_1.js
var testData = {
tags: 'tag1 tag2 tag3',
setup: 'one_tier'
}
/test/file_2.js
var testData = {
tags: 'tag3',
setup: 'two_tier'
}
我的代码:index.js
let fs = require("fs")
const glob = require("glob");
var getDirectories = function (src, callback) {
glob(src + '/**/*.js', callback);
};
getDirectories('tests', function (err, res) {
if (err) {
console.log('Error', err);
}
else {
var listOfFiles = res;
for (let val of listOfFiles){
///// HERE we have to get the Tags and setup from each js file////
}
}