Created
November 28, 2013 19:54
-
-
Save otakustay/7697339 to your computer and use it in GitHub Desktop.
错误的javascript写法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs-extra'); | |
var GitHubAPI = require('github'); | |
console.log('Request archive link for er'); | |
var github = new GitHubAPI({ version: '3.0.0' }); | |
github.repos.getArchiveLink( | |
{ | |
user: 'ecomfe', | |
repo: 'er', | |
archive_format: 'zipball', | |
ref: '3.1.0-dev' | |
}, | |
function (err, data) { | |
var url = require('url').parse(data.meta.location); | |
console.log('Request zip file at "' + url.href + '"'); | |
var request = require('https').get( | |
{ | |
hostname: url.hostname, | |
path: url.path, | |
headers: { | |
'Accept': '*/*', | |
'User-Agent': 'Document Generator' | |
} | |
}, | |
function (response) { | |
console.log('Received from github with status code ' + response.statusCode); | |
var unzip = require('unzip').Extract({ path: 'output' }); | |
response.pipe(unzip); | |
unzip.on( | |
'close', | |
function () { | |
console.log('Start generate documents with jsduck'); | |
var dir = fs.readdirSync('output')[0]; | |
console.log(process.cwd()); | |
var jsduck = require('child_process').spawn( | |
'jsduck', | |
['--config=jsduck/config.json'], | |
{ | |
cwd: require('path').join('output', dir), | |
stdio: 'inherit' | |
} | |
); | |
jsduck.on( | |
'close', | |
function (code) { | |
console.log('Remove old documents'); | |
fs.remove( | |
'doc', | |
function () { | |
console.log('Copy document to destination folder'); | |
fs.copy( | |
require('path').join('output', dir, 'doc', 'api'), | |
'doc', | |
function () { | |
console.log('Remove output folder'); | |
fs.remove( | |
'output', | |
function () { | |
console.log('Document generated at "doc"'); | |
} | |
); | |
} | |
); | |
} | |
); | |
} | |
); | |
} | |
); | |
} | |
); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment