-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·37 lines (32 loc) · 1.16 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
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var lib = require('./lib.js');
var defaults = {
repos: path.join(__dirname, 'repos.json'),
out: 'readmes'
};
var argv = require('minimist')(process.argv.slice(2), { default: defaults });
//make paths relative to CWD unless they're absolute paths
var REPOS = path.resolve(process.cwd(), argv.repos);
var OUTPATH = path.resolve(process.cwd(), argv.out);
// Create output dir if it does not exist
if (!lib.fileOrDirExists(OUTPATH, true)) {
fs.mkdirSync(OUTPATH);
console.log('Creating directory %s', OUTPATH);
}
// Load repos.json at specified path, if it exists; if not, throw error and exit.
var repoList;
if (lib.fileOrDirExists(REPOS)) {
repoList = require(REPOS);
} else {
console.error('ERROR: Cannot access ', REPOS);
process.exit(1);
}
// Iterate through repos in JSON file and download the READMEs
var nRepos = repoList.repos.length;
for (i = 0; i < nRepos; i++) {
// console.log('org = ' + repoList.repos[i].org + ' repo = ' + repoList.repos[i].repoName )
//writeReadme(repoList.repos[i].org, repoList.repos[i].repoName , OUTPATH);
lib.processReadme(repoList.repos[i], OUTPATH);
}