This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
executable file
·81 lines (60 loc) · 1.86 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /usr/bin/env node
var path = require('path')
var join = path.join
var fs = require('fs')
// io.js native modules
var native_modules = [
'assert', 'buffer', 'child_process', 'cluster', 'console',
'constants', 'crypto', 'dgram', 'dns', 'domain', 'events',
'freelist', 'fs', 'http', 'https', 'module', 'net', 'os',
'path', 'process', 'punycode', 'querystring', 'readline',
'repl', 'smalloc', 'stream', 'string_decoder', 'sys',
'timers', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib'
]
var electron_modules = [
'app', 'auto-updater', 'browser-window', 'content-tracing',
'dialog', 'global-shortcut', 'ipc', 'menu', 'menu-item',
'power-monitor', 'power-save-blocker', 'protocol', 'tray',
'remote', 'web-frame', 'clipboard', 'crash-reporter',
'native-image', 'screen', 'shell'
]
var argv = require('minimist')(process.argv.slice(2), {
alias: {
f: 'filter',
p: 'prelude',
v: 'version',
e: 'electron',
'ignore-missing': 'ignoreMissing'
},
boolean: ['electron', 'version']
})
//startup noderify with optimist's defaults
var opts = require('rc')('noderify', {}, argv)
if(opts.electron) argv.shebang = false
if(opts.version)
return console.log(require('./package.json').version)
var filter = [].concat(opts.filter)
.concat(native_modules)
.concat(opts.electron ? electron_modules : [])
if(!opts._[0]) {
console.error('usage: noderify entry.js > bundle.js')
process.exit(1)
}
var entry = opts.entry || path.resolve(opts._[0])
//var replace = {}
//deps
// .pipe(deterministic(function (err, content, deps, entry) {
// if(err) throw err
// console.log(pack(content, deps, entry))
// }))
//
//deps.end(entry)
require('./inject')({
entry: entry,
filter: filter,
replace: opts.replace || {},
ignoreMissing: opts.ignoreMissing
}, function (err, src) {
if(err) throw err
console.log(src)
})