-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.js
42 lines (36 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
var fs = require('fs');
var Registry = require('npm-registry');
var async = require('async');
var tools = require('./tools');
var KEY_WORDS = 'react-native';
var npm = new Registry({
registry: Registry.mirrors.npmjs,
});
async.waterfall([
function (callback) {
npm.packages.keyword(KEY_WORDS, callback);
},
function (packages, callback) {
console.log('Packages count:', packages.length);
var tasks = packages.map(function (packageInfo) {
return function (cb) {
tools.fetchByPackageInfo(packageInfo, cb);
};
});
async.parallelLimit(tasks, 10, callback);
},
function (jsonResultArray, callback) {
console.log('jsonResultArray.length:', jsonResultArray.length);
var initMarkdown = fs.readFileSync('./data/init_readme.md');
var markdown = tools.jsonResultToMarkdown(jsonResultArray);
initMarkdown += markdown;
callback(null, initMarkdown);
},
function (markdown, callback) {
fs.writeFileSync('./README.md', markdown);
callback(null, 'Finished');
}
], function (err, result) {
console.log(err, result);
});