保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 9bdb95c9e34cef640534e5e5a1e2225a80442000
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
43
#!/usr/bin/env node
 
var request   = require('request')
  , fs        = require('fs')
 
  , uvheadloc = 'https://raw.github.com/joyent/libuv/master/include/uv.h'
  , defreg    = /^\s*XX\(\s*([\-\d]+),\s*([A-Z]+),\s*"([^"]*)"\s*\)\s*\\?$/
 
 
request(uvheadloc, function (err, response) {
  if (err)
    throw err
 
  var data, out
 
  data = response.body
    .split('\n')
    .map(function (line) { return line.match(defreg) })
    .filter(function (match) { return match })
    .map(function (match) { return {
        errno: parseInt(match[1], 10)
      , code: match[2]
      , description: match[3]
    }})
 
  out = 'var all = module.exports.all = ' + JSON.stringify(data, 0, 1) + '\n\n'
 
  out += '\nmodule.exports.errno = {\n    '
    + data.map(function (e, i) {
        return '\'' + e.errno + '\': all[' + i + ']'
      }).join('\n  , ')
    + '\n}\n\n'
 
  out += '\nmodule.exports.code = {\n    '
    + data.map(function (e, i) {
        return '\'' + e.code + '\': all[' + i + ']'
      }).join('\n  , ')
    + '\n}\n\n'
 
  out += '\nmodule.exports.custom = require("./custom")(module.exports)\n'
 
  fs.writeFile('errno.js', out)
})