source: trip-planner-front/node_modules/errno/build.js@ 6fe77af

Last change on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#!/usr/bin/env node
2
3var request = require('request')
4 , fs = require('fs')
5
6 , uvheadloc = 'https://raw.github.com/joyent/libuv/master/include/uv.h'
7 , defreg = /^\s*XX\(\s*([\-\d]+),\s*([A-Z]+),\s*"([^"]*)"\s*\)\s*\\?$/
8
9
10request(uvheadloc, function (err, response) {
11 if (err)
12 throw err
13
14 var data, out
15
16 data = response.body
17 .split('\n')
18 .map(function (line) { return line.match(defreg) })
19 .filter(function (match) { return match })
20 .map(function (match) { return {
21 errno: parseInt(match[1], 10)
22 , code: match[2]
23 , description: match[3]
24 }})
25
26 out = 'var all = module.exports.all = ' + JSON.stringify(data, 0, 1) + '\n\n'
27
28 out += '\nmodule.exports.errno = {\n '
29 + data.map(function (e, i) {
30 return '\'' + e.errno + '\': all[' + i + ']'
31 }).join('\n , ')
32 + '\n}\n\n'
33
34 out += '\nmodule.exports.code = {\n '
35 + data.map(function (e, i) {
36 return '\'' + e.code + '\': all[' + i + ']'
37 }).join('\n , ')
38 + '\n}\n\n'
39
40 out += '\nmodule.exports.custom = require("./custom")(module.exports)\n'
41
42 fs.writeFile('errno.js', out)
43})
Note: See TracBrowser for help on using the repository browser.