Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initArchives: function (options) {
var _this = this;
return vow.all(options.languages
.filter(function (lang) {
return options.archive[lang];
})
.map(function (lang) {
var archive = new Archive(options, lang);
_this.archive[lang] = archive;
return archive.init();
}));
},
_readYmlFileAndReplacePlaceholders: function (output, suffix, contentWrapper) {
var path = output + suffix;
return Vow.all([this._getConfig(output), this._readFile(path)])
.spread(function (config, content) {
for (var key in config) {
if (config.hasOwnProperty(key)) {
content = content.replace(new RegExp('%' + key + '%', 'g'), config[key]);
}
}
return {
path: path.replace('yml', 'js'),
content: contentWrapper.call(this, yml.safeLoad(content))
};
}, this);
},
.spread(function(obj, docs, libraries, people) {
return vow
.all([
addDynamicNodes(obj.sitemap, obj.routes, docs, people),
addLibraryNodes(obj.sitemap, obj.routes, obj.libraryNodes, libraries)
]).spread(function(dynamic, libraries) {
return {
sitemap: removeCircularReferences(obj.sitemap),
routes: obj.routes,
docs: docs,
urls: dynamic,
people: people
};
});
})
.then(function(content) {
removeFiles: function() {
return vow.all([
providers.getProviderFile().exists({ path: dataTargetPath }),
providers.getProviderFile().exists({ path: sitemapTargetPath })
]).spread(function(dataExists, sitemapExists) {
var promises = [];
if(dataExists) {
promises.push(providers.getProviderFile().remove({ path: dataTargetPath }));
}
if(sitemapExists) {
promises.push(providers.getProviderFile().remove({ path: sitemapTargetPath }));
}
return vow.all(promises);
});
},
module.exports = function (targets, loadedConfig) {
var config = new Configuration(loadedConfig);
return vow.all([scan(targets, config), loadRules()])
.spread(function (entities, rules) {
return vow.all(Object.keys(rules).map(function (rule) {
return new rules[rule]().check(entities);
}));
})
.then(function (res) {
return _(res)
.flatten()
.sortBy('path')
.value();
});
};
return vow.all(langs.map(function (lang) {
return vow.all([
vowFs.read(path.join(errorBundlesPath, 'error-404', 'error-404.' + lang + '.html'), 'utf-8'),
vowFs.read(path.join(errorBundlesPath, 'error-500', 'error-500.' + lang + '.html'), 'utf-8')
]).spread(function (error404, error500) {
errorPages[lang] = {
error404: error404.replace(/\{STATICS_HOST\}/g, staticsUrl),
error500: error500.replace(/\{STATICS_HOST\}/g, staticsUrl)
};
});
}))
.then(function () {
function run(levels, plain, done) {
vow.all(levels.map(function (level) {
return (new Level(level, plain)).load();
})).then(done, done);
}
.builder(function (langFilenames, privJs) {
return Vow.all(
langFilenames.map(function (filename) {
return vowFs.read(filename);
})
).then(function (langResults) {
return langResults.join('\n') + privJs;
});
})
.createTech();
.then(function () {
return Vow.all(levelList.map(function (level) {
return level.load();
}))
.then(function () {
levelsToCache.forEach(function (level) {
cache.set(level.getPath(), level.getBlocks());
});
_this.node.resolveTarget(target, new Levels(levelList));
});
});
},
run: function(libraryNodes) {
logger.info(MSG.INFO.START);
var libraries = {};
return vow
.all(libraryNodes.map(function(node) {
return loadLibraryVersions(config.get('github:librariesRepository'), node, libraries);
}))
.then(
function() {
logger.info(MSG.INFO.SUCCESS);
return libraries;
},
function() { logger.error(MSG.ERROR); }
);
}
};