dragonfly_chrome_headless 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dragonfly_chrome_headless.gemspec +27 -0
- data/lib/dragonfly_chrome_headless.rb +9 -0
- data/lib/dragonfly_chrome_headless/plugin.rb +17 -0
- data/lib/dragonfly_chrome_headless/processors/rasterize.rb +33 -0
- data/lib/dragonfly_chrome_headless/version.rb +3 -0
- data/node_modules/.bin/chrome-remote-interface +1 -0
- data/node_modules/.bin/mkdirp +1 -0
- data/node_modules/.bin/rimraf +1 -0
- data/node_modules/@types/core-js/LICENSE +21 -0
- data/node_modules/@types/core-js/README.md +16 -0
- data/node_modules/@types/core-js/index.d.ts +2452 -0
- data/node_modules/@types/core-js/package.json +85 -0
- data/node_modules/@types/mkdirp/README.md +18 -0
- data/node_modules/@types/mkdirp/index.d.ts +14 -0
- data/node_modules/@types/mkdirp/package.json +77 -0
- data/node_modules/@types/mkdirp/types-metadata.json +25 -0
- data/node_modules/@types/node/README.md +16 -0
- data/node_modules/@types/node/index.d.ts +4132 -0
- data/node_modules/@types/node/package.json +84 -0
- data/node_modules/balanced-match/.npmignore +5 -0
- data/node_modules/balanced-match/LICENSE.md +21 -0
- data/node_modules/balanced-match/README.md +91 -0
- data/node_modules/balanced-match/index.js +59 -0
- data/node_modules/balanced-match/package.json +112 -0
- data/node_modules/brace-expansion/README.md +123 -0
- data/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/brace-expansion/package.json +114 -0
- data/node_modules/chrome-launcher/.clang-format +6 -0
- data/node_modules/chrome-launcher/.npmignore +11 -0
- data/node_modules/chrome-launcher/README.md +123 -0
- data/node_modules/chrome-launcher/ask.js +32 -0
- data/node_modules/chrome-launcher/ask.ts +35 -0
- data/node_modules/chrome-launcher/chrome-finder.js +157 -0
- data/node_modules/chrome-launcher/chrome-finder.ts +186 -0
- data/node_modules/chrome-launcher/chrome-launcher.js +245 -0
- data/node_modules/chrome-launcher/chrome-launcher.ts +312 -0
- data/node_modules/chrome-launcher/compiled-check.js +14 -0
- data/node_modules/chrome-launcher/flags.js +27 -0
- data/node_modules/chrome-launcher/flags.ts +26 -0
- data/node_modules/chrome-launcher/index.js +7 -0
- data/node_modules/chrome-launcher/index.ts +1 -0
- data/node_modules/chrome-launcher/manual-chrome-launcher.js +30 -0
- data/node_modules/chrome-launcher/package.json +116 -0
- data/node_modules/chrome-launcher/random-port.js +24 -0
- data/node_modules/chrome-launcher/random-port.ts +23 -0
- data/node_modules/chrome-launcher/tsconfig.json +19 -0
- data/node_modules/chrome-launcher/utils.js +52 -0
- data/node_modules/chrome-launcher/utils.ts +44 -0
- data/node_modules/chrome-launcher/yarn.lock +1486 -0
- data/node_modules/chrome-remote-interface/LICENSE +18 -0
- data/node_modules/chrome-remote-interface/README.md +849 -0
- data/node_modules/chrome-remote-interface/bin/client.js +337 -0
- data/node_modules/chrome-remote-interface/chrome-remote-interface.js +11 -0
- data/node_modules/chrome-remote-interface/index.js +39 -0
- data/node_modules/chrome-remote-interface/lib/api.js +84 -0
- data/node_modules/chrome-remote-interface/lib/chrome.js +307 -0
- data/node_modules/chrome-remote-interface/lib/defaults.js +4 -0
- data/node_modules/chrome-remote-interface/lib/devtools.js +245 -0
- data/node_modules/chrome-remote-interface/lib/external-request.js +28 -0
- data/node_modules/chrome-remote-interface/lib/protocol.json +13780 -0
- data/node_modules/chrome-remote-interface/lib/websocket-wrapper.js +32 -0
- data/node_modules/chrome-remote-interface/package.json +128 -0
- data/node_modules/chrome-remote-interface/webpack.config.js +55 -0
- data/node_modules/commander/Readme.md +195 -0
- data/node_modules/commander/index.js +851 -0
- data/node_modules/commander/package.json +92 -0
- data/node_modules/concat-map/.travis.yml +4 -0
- data/node_modules/concat-map/LICENSE +18 -0
- data/node_modules/concat-map/README.markdown +62 -0
- data/node_modules/concat-map/example/map.js +6 -0
- data/node_modules/concat-map/index.js +13 -0
- data/node_modules/concat-map/package.json +117 -0
- data/node_modules/concat-map/test/map.js +39 -0
- data/node_modules/debug/.coveralls.yml +1 -0
- data/node_modules/debug/.eslintrc +11 -0
- data/node_modules/debug/.npmignore +9 -0
- data/node_modules/debug/.travis.yml +14 -0
- data/node_modules/debug/CHANGELOG.md +357 -0
- data/node_modules/debug/LICENSE +19 -0
- data/node_modules/debug/Makefile +50 -0
- data/node_modules/debug/Readme.md +312 -0
- data/node_modules/debug/component.json +19 -0
- data/node_modules/debug/karma.conf.js +70 -0
- data/node_modules/debug/node.js +1 -0
- data/node_modules/debug/package.json +124 -0
- data/node_modules/debug/src/browser.js +185 -0
- data/node_modules/debug/src/debug.js +202 -0
- data/node_modules/debug/src/index.js +10 -0
- data/node_modules/debug/src/node.js +246 -0
- data/node_modules/fs.realpath/LICENSE +43 -0
- data/node_modules/fs.realpath/README.md +33 -0
- data/node_modules/fs.realpath/index.js +66 -0
- data/node_modules/fs.realpath/old.js +303 -0
- data/node_modules/fs.realpath/package.json +94 -0
- data/node_modules/glob/LICENSE +15 -0
- data/node_modules/glob/README.md +368 -0
- data/node_modules/glob/changelog.md +67 -0
- data/node_modules/glob/common.js +240 -0
- data/node_modules/glob/glob.js +790 -0
- data/node_modules/glob/package.json +112 -0
- data/node_modules/glob/sync.js +486 -0
- data/node_modules/html-pdf-chrome/.npmignore +9 -0
- data/node_modules/html-pdf-chrome/LICENSE +21 -0
- data/node_modules/html-pdf-chrome/README.md +165 -0
- data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.d.ts +87 -0
- data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.js +4 -0
- data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.js.map +1 -0
- data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.d.ts +120 -0
- data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.js +206 -0
- data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.js.map +1 -0
- data/node_modules/html-pdf-chrome/lib/src/CreateResult.d.ts +70 -0
- data/node_modules/html-pdf-chrome/lib/src/CreateResult.js +98 -0
- data/node_modules/html-pdf-chrome/lib/src/CreateResult.js.map +1 -0
- data/node_modules/html-pdf-chrome/lib/src/index.d.ts +72 -0
- data/node_modules/html-pdf-chrome/lib/src/index.js +123 -0
- data/node_modules/html-pdf-chrome/lib/src/index.js.map +1 -0
- data/node_modules/html-pdf-chrome/package.json +133 -0
- data/node_modules/html-pdf-chrome/src/ChromePrintOptions.ts +99 -0
- data/node_modules/html-pdf-chrome/src/CompletionTrigger.ts +201 -0
- data/node_modules/html-pdf-chrome/src/CreateResult.ts +100 -0
- data/node_modules/html-pdf-chrome/src/index.ts +179 -0
- data/node_modules/inflight/LICENSE +15 -0
- data/node_modules/inflight/README.md +37 -0
- data/node_modules/inflight/inflight.js +54 -0
- data/node_modules/inflight/package.json +105 -0
- data/node_modules/inherits/LICENSE +16 -0
- data/node_modules/inherits/README.md +42 -0
- data/node_modules/inherits/inherits.js +7 -0
- data/node_modules/inherits/inherits_browser.js +23 -0
- data/node_modules/inherits/package.json +97 -0
- data/node_modules/lighthouse-logger/README.md +4 -0
- data/node_modules/lighthouse-logger/index.js +212 -0
- data/node_modules/lighthouse-logger/package.json +69 -0
- data/node_modules/lighthouse-logger/yarn.lock +13 -0
- data/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/minimatch/README.md +209 -0
- data/node_modules/minimatch/minimatch.js +923 -0
- data/node_modules/minimatch/package.json +99 -0
- data/node_modules/minimist/.travis.yml +4 -0
- data/node_modules/minimist/LICENSE +18 -0
- data/node_modules/minimist/example/parse.js +2 -0
- data/node_modules/minimist/index.js +187 -0
- data/node_modules/minimist/package.json +101 -0
- data/node_modules/minimist/readme.markdown +73 -0
- data/node_modules/minimist/test/dash.js +24 -0
- data/node_modules/minimist/test/default_bool.js +20 -0
- data/node_modules/minimist/test/dotted.js +16 -0
- data/node_modules/minimist/test/long.js +31 -0
- data/node_modules/minimist/test/parse.js +318 -0
- data/node_modules/minimist/test/parse_modified.js +9 -0
- data/node_modules/minimist/test/short.js +67 -0
- data/node_modules/minimist/test/whitespace.js +8 -0
- data/node_modules/mkdirp/.travis.yml +8 -0
- data/node_modules/mkdirp/LICENSE +21 -0
- data/node_modules/mkdirp/bin/cmd.js +33 -0
- data/node_modules/mkdirp/bin/usage.txt +12 -0
- data/node_modules/mkdirp/examples/pow.js +6 -0
- data/node_modules/mkdirp/index.js +98 -0
- data/node_modules/mkdirp/package.json +93 -0
- data/node_modules/mkdirp/readme.markdown +100 -0
- data/node_modules/mkdirp/test/chmod.js +41 -0
- data/node_modules/mkdirp/test/clobber.js +38 -0
- data/node_modules/mkdirp/test/mkdirp.js +28 -0
- data/node_modules/mkdirp/test/opts_fs.js +29 -0
- data/node_modules/mkdirp/test/opts_fs_sync.js +27 -0
- data/node_modules/mkdirp/test/perm.js +32 -0
- data/node_modules/mkdirp/test/perm_sync.js +36 -0
- data/node_modules/mkdirp/test/race.js +37 -0
- data/node_modules/mkdirp/test/rel.js +32 -0
- data/node_modules/mkdirp/test/return.js +25 -0
- data/node_modules/mkdirp/test/return_sync.js +24 -0
- data/node_modules/mkdirp/test/root.js +19 -0
- data/node_modules/mkdirp/test/sync.js +32 -0
- data/node_modules/mkdirp/test/umask.js +28 -0
- data/node_modules/mkdirp/test/umask_sync.js +32 -0
- data/node_modules/ms/README.md +51 -0
- data/node_modules/ms/index.js +152 -0
- data/node_modules/ms/license.md +21 -0
- data/node_modules/ms/package.json +109 -0
- data/node_modules/once/LICENSE +15 -0
- data/node_modules/once/README.md +79 -0
- data/node_modules/once/once.js +42 -0
- data/node_modules/once/package.json +101 -0
- data/node_modules/path-is-absolute/index.js +20 -0
- data/node_modules/path-is-absolute/license +21 -0
- data/node_modules/path-is-absolute/package.json +111 -0
- data/node_modules/path-is-absolute/readme.md +59 -0
- data/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/rimraf/README.md +101 -0
- data/node_modules/rimraf/bin.js +50 -0
- data/node_modules/rimraf/package.json +99 -0
- data/node_modules/rimraf/rimraf.js +363 -0
- data/node_modules/ultron/LICENSE +22 -0
- data/node_modules/ultron/index.js +138 -0
- data/node_modules/ultron/package.json +112 -0
- data/node_modules/wrappy/LICENSE +15 -0
- data/node_modules/wrappy/README.md +36 -0
- data/node_modules/wrappy/package.json +97 -0
- data/node_modules/wrappy/wrappy.js +33 -0
- data/node_modules/ws/LICENSE +21 -0
- data/node_modules/ws/README.md +259 -0
- data/node_modules/ws/SECURITY.md +33 -0
- data/node_modules/ws/index.js +15 -0
- data/node_modules/ws/lib/BufferUtil.fallback.js +56 -0
- data/node_modules/ws/lib/BufferUtil.js +15 -0
- data/node_modules/ws/lib/ErrorCodes.js +28 -0
- data/node_modules/ws/lib/EventTarget.js +158 -0
- data/node_modules/ws/lib/Extensions.js +69 -0
- data/node_modules/ws/lib/PerMessageDeflate.js +339 -0
- data/node_modules/ws/lib/Receiver.js +520 -0
- data/node_modules/ws/lib/Sender.js +438 -0
- data/node_modules/ws/lib/Validation.fallback.js +9 -0
- data/node_modules/ws/lib/Validation.js +17 -0
- data/node_modules/ws/lib/WebSocket.js +705 -0
- data/node_modules/ws/lib/WebSocketServer.js +336 -0
- data/node_modules/ws/package.json +122 -0
- data/package.json +26 -0
- data/samples/sample.html +13 -0
- data/script/rasterize.js +18 -0
- metadata +325 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* Detect Electron renderer process, which is node, but we should
|
3
|
+
* treat as a browser.
|
4
|
+
*/
|
5
|
+
|
6
|
+
if (typeof process !== 'undefined' && process.type === 'renderer') {
|
7
|
+
module.exports = require('./browser.js');
|
8
|
+
} else {
|
9
|
+
module.exports = require('./node.js');
|
10
|
+
}
|
@@ -0,0 +1,246 @@
|
|
1
|
+
/**
|
2
|
+
* Module dependencies.
|
3
|
+
*/
|
4
|
+
|
5
|
+
var tty = require('tty');
|
6
|
+
var util = require('util');
|
7
|
+
|
8
|
+
/**
|
9
|
+
* This is the Node.js implementation of `debug()`.
|
10
|
+
*
|
11
|
+
* Expose `debug()` as the module.
|
12
|
+
*/
|
13
|
+
|
14
|
+
exports = module.exports = require('./debug');
|
15
|
+
exports.init = init;
|
16
|
+
exports.log = log;
|
17
|
+
exports.formatArgs = formatArgs;
|
18
|
+
exports.save = save;
|
19
|
+
exports.load = load;
|
20
|
+
exports.useColors = useColors;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Colors.
|
24
|
+
*/
|
25
|
+
|
26
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
30
|
+
*
|
31
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
32
|
+
*/
|
33
|
+
|
34
|
+
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
35
|
+
return /^debug_/i.test(key);
|
36
|
+
}).reduce(function (obj, key) {
|
37
|
+
// camel-case
|
38
|
+
var prop = key
|
39
|
+
.substring(6)
|
40
|
+
.toLowerCase()
|
41
|
+
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
|
42
|
+
|
43
|
+
// coerce string value into JS value
|
44
|
+
var val = process.env[key];
|
45
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
|
46
|
+
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
|
47
|
+
else if (val === 'null') val = null;
|
48
|
+
else val = Number(val);
|
49
|
+
|
50
|
+
obj[prop] = val;
|
51
|
+
return obj;
|
52
|
+
}, {});
|
53
|
+
|
54
|
+
/**
|
55
|
+
* The file descriptor to write the `debug()` calls to.
|
56
|
+
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
57
|
+
*
|
58
|
+
* $ DEBUG_FD=3 node script.js 3>debug.log
|
59
|
+
*/
|
60
|
+
|
61
|
+
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
62
|
+
|
63
|
+
if (1 !== fd && 2 !== fd) {
|
64
|
+
util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')()
|
65
|
+
}
|
66
|
+
|
67
|
+
var stream = 1 === fd ? process.stdout :
|
68
|
+
2 === fd ? process.stderr :
|
69
|
+
createWritableStdioStream(fd);
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
73
|
+
*/
|
74
|
+
|
75
|
+
function useColors() {
|
76
|
+
return 'colors' in exports.inspectOpts
|
77
|
+
? Boolean(exports.inspectOpts.colors)
|
78
|
+
: tty.isatty(fd);
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Map %o to `util.inspect()`, all on a single line.
|
83
|
+
*/
|
84
|
+
|
85
|
+
exports.formatters.o = function(v) {
|
86
|
+
this.inspectOpts.colors = this.useColors;
|
87
|
+
return util.inspect(v, this.inspectOpts)
|
88
|
+
.replace(/\s*\n\s*/g, ' ');
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Map %o to `util.inspect()`, allowing multiple lines if needed.
|
93
|
+
*/
|
94
|
+
|
95
|
+
exports.formatters.O = function(v) {
|
96
|
+
this.inspectOpts.colors = this.useColors;
|
97
|
+
return util.inspect(v, this.inspectOpts);
|
98
|
+
};
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Adds ANSI color escape codes if enabled.
|
102
|
+
*
|
103
|
+
* @api public
|
104
|
+
*/
|
105
|
+
|
106
|
+
function formatArgs(args) {
|
107
|
+
var name = this.namespace;
|
108
|
+
var useColors = this.useColors;
|
109
|
+
|
110
|
+
if (useColors) {
|
111
|
+
var c = this.color;
|
112
|
+
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
|
113
|
+
|
114
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
115
|
+
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
|
116
|
+
} else {
|
117
|
+
args[0] = new Date().toUTCString()
|
118
|
+
+ ' ' + name + ' ' + args[0];
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Invokes `util.format()` with the specified arguments and writes to `stream`.
|
124
|
+
*/
|
125
|
+
|
126
|
+
function log() {
|
127
|
+
return stream.write(util.format.apply(util, arguments) + '\n');
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Save `namespaces`.
|
132
|
+
*
|
133
|
+
* @param {String} namespaces
|
134
|
+
* @api private
|
135
|
+
*/
|
136
|
+
|
137
|
+
function save(namespaces) {
|
138
|
+
if (null == namespaces) {
|
139
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
140
|
+
// string 'null' or 'undefined'. Just delete instead.
|
141
|
+
delete process.env.DEBUG;
|
142
|
+
} else {
|
143
|
+
process.env.DEBUG = namespaces;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Load `namespaces`.
|
149
|
+
*
|
150
|
+
* @return {String} returns the previously persisted debug modes
|
151
|
+
* @api private
|
152
|
+
*/
|
153
|
+
|
154
|
+
function load() {
|
155
|
+
return process.env.DEBUG;
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Copied from `node/src/node.js`.
|
160
|
+
*
|
161
|
+
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
162
|
+
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
163
|
+
*/
|
164
|
+
|
165
|
+
function createWritableStdioStream (fd) {
|
166
|
+
var stream;
|
167
|
+
var tty_wrap = process.binding('tty_wrap');
|
168
|
+
|
169
|
+
// Note stream._type is used for test-module-load-list.js
|
170
|
+
|
171
|
+
switch (tty_wrap.guessHandleType(fd)) {
|
172
|
+
case 'TTY':
|
173
|
+
stream = new tty.WriteStream(fd);
|
174
|
+
stream._type = 'tty';
|
175
|
+
|
176
|
+
// Hack to have stream not keep the event loop alive.
|
177
|
+
// See https://github.com/joyent/node/issues/1726
|
178
|
+
if (stream._handle && stream._handle.unref) {
|
179
|
+
stream._handle.unref();
|
180
|
+
}
|
181
|
+
break;
|
182
|
+
|
183
|
+
case 'FILE':
|
184
|
+
var fs = require('fs');
|
185
|
+
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
186
|
+
stream._type = 'fs';
|
187
|
+
break;
|
188
|
+
|
189
|
+
case 'PIPE':
|
190
|
+
case 'TCP':
|
191
|
+
var net = require('net');
|
192
|
+
stream = new net.Socket({
|
193
|
+
fd: fd,
|
194
|
+
readable: false,
|
195
|
+
writable: true
|
196
|
+
});
|
197
|
+
|
198
|
+
// FIXME Should probably have an option in net.Socket to create a
|
199
|
+
// stream from an existing fd which is writable only. But for now
|
200
|
+
// we'll just add this hack and set the `readable` member to false.
|
201
|
+
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
202
|
+
stream.readable = false;
|
203
|
+
stream.read = null;
|
204
|
+
stream._type = 'pipe';
|
205
|
+
|
206
|
+
// FIXME Hack to have stream not keep the event loop alive.
|
207
|
+
// See https://github.com/joyent/node/issues/1726
|
208
|
+
if (stream._handle && stream._handle.unref) {
|
209
|
+
stream._handle.unref();
|
210
|
+
}
|
211
|
+
break;
|
212
|
+
|
213
|
+
default:
|
214
|
+
// Probably an error on in uv_guess_handle()
|
215
|
+
throw new Error('Implement me. Unknown stream file type!');
|
216
|
+
}
|
217
|
+
|
218
|
+
// For supporting legacy API we put the FD here.
|
219
|
+
stream.fd = fd;
|
220
|
+
|
221
|
+
stream._isStdio = true;
|
222
|
+
|
223
|
+
return stream;
|
224
|
+
}
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Init logic for `debug` instances.
|
228
|
+
*
|
229
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
230
|
+
* differently for a particular `debug` instance.
|
231
|
+
*/
|
232
|
+
|
233
|
+
function init (debug) {
|
234
|
+
debug.inspectOpts = {};
|
235
|
+
|
236
|
+
var keys = Object.keys(exports.inspectOpts);
|
237
|
+
for (var i = 0; i < keys.length; i++) {
|
238
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Enable namespaces listed in `process.env.DEBUG` initially.
|
244
|
+
*/
|
245
|
+
|
246
|
+
exports.enable(load());
|
@@ -0,0 +1,43 @@
|
|
1
|
+
The ISC License
|
2
|
+
|
3
|
+
Copyright (c) Isaac Z. Schlueter and Contributors
|
4
|
+
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
16
|
+
|
17
|
+
----
|
18
|
+
|
19
|
+
This library bundles a version of the `fs.realpath` and `fs.realpathSync`
|
20
|
+
methods from Node.js v0.10 under the terms of the Node.js MIT license.
|
21
|
+
|
22
|
+
Node's license follows, also included at the header of `old.js` which contains
|
23
|
+
the licensed code:
|
24
|
+
|
25
|
+
Copyright Joyent, Inc. and other Node contributors.
|
26
|
+
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
28
|
+
copy of this software and associated documentation files (the "Software"),
|
29
|
+
to deal in the Software without restriction, including without limitation
|
30
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
31
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
32
|
+
Software is furnished to do so, subject to the following conditions:
|
33
|
+
|
34
|
+
The above copyright notice and this permission notice shall be included in
|
35
|
+
all copies or substantial portions of the Software.
|
36
|
+
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
38
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
39
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
40
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
41
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
42
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
43
|
+
DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# fs.realpath
|
2
|
+
|
3
|
+
A backwards-compatible fs.realpath for Node v6 and above
|
4
|
+
|
5
|
+
In Node v6, the JavaScript implementation of fs.realpath was replaced
|
6
|
+
with a faster (but less resilient) native implementation. That raises
|
7
|
+
new and platform-specific errors and cannot handle long or excessively
|
8
|
+
symlink-looping paths.
|
9
|
+
|
10
|
+
This module handles those cases by detecting the new errors and
|
11
|
+
falling back to the JavaScript implementation. On versions of Node
|
12
|
+
prior to v6, it has no effect.
|
13
|
+
|
14
|
+
## USAGE
|
15
|
+
|
16
|
+
```js
|
17
|
+
var rp = require('fs.realpath')
|
18
|
+
|
19
|
+
// async version
|
20
|
+
rp.realpath(someLongAndLoopingPath, function (er, real) {
|
21
|
+
// the ELOOP was handled, but it was a bit slower
|
22
|
+
})
|
23
|
+
|
24
|
+
// sync version
|
25
|
+
var real = rp.realpathSync(someLongAndLoopingPath)
|
26
|
+
|
27
|
+
// monkeypatch at your own risk!
|
28
|
+
// This replaces the fs.realpath/fs.realpathSync builtins
|
29
|
+
rp.monkeypatch()
|
30
|
+
|
31
|
+
// un-do the monkeypatching
|
32
|
+
rp.unmonkeypatch()
|
33
|
+
```
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module.exports = realpath
|
2
|
+
realpath.realpath = realpath
|
3
|
+
realpath.sync = realpathSync
|
4
|
+
realpath.realpathSync = realpathSync
|
5
|
+
realpath.monkeypatch = monkeypatch
|
6
|
+
realpath.unmonkeypatch = unmonkeypatch
|
7
|
+
|
8
|
+
var fs = require('fs')
|
9
|
+
var origRealpath = fs.realpath
|
10
|
+
var origRealpathSync = fs.realpathSync
|
11
|
+
|
12
|
+
var version = process.version
|
13
|
+
var ok = /^v[0-5]\./.test(version)
|
14
|
+
var old = require('./old.js')
|
15
|
+
|
16
|
+
function newError (er) {
|
17
|
+
return er && er.syscall === 'realpath' && (
|
18
|
+
er.code === 'ELOOP' ||
|
19
|
+
er.code === 'ENOMEM' ||
|
20
|
+
er.code === 'ENAMETOOLONG'
|
21
|
+
)
|
22
|
+
}
|
23
|
+
|
24
|
+
function realpath (p, cache, cb) {
|
25
|
+
if (ok) {
|
26
|
+
return origRealpath(p, cache, cb)
|
27
|
+
}
|
28
|
+
|
29
|
+
if (typeof cache === 'function') {
|
30
|
+
cb = cache
|
31
|
+
cache = null
|
32
|
+
}
|
33
|
+
origRealpath(p, cache, function (er, result) {
|
34
|
+
if (newError(er)) {
|
35
|
+
old.realpath(p, cache, cb)
|
36
|
+
} else {
|
37
|
+
cb(er, result)
|
38
|
+
}
|
39
|
+
})
|
40
|
+
}
|
41
|
+
|
42
|
+
function realpathSync (p, cache) {
|
43
|
+
if (ok) {
|
44
|
+
return origRealpathSync(p, cache)
|
45
|
+
}
|
46
|
+
|
47
|
+
try {
|
48
|
+
return origRealpathSync(p, cache)
|
49
|
+
} catch (er) {
|
50
|
+
if (newError(er)) {
|
51
|
+
return old.realpathSync(p, cache)
|
52
|
+
} else {
|
53
|
+
throw er
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
function monkeypatch () {
|
59
|
+
fs.realpath = realpath
|
60
|
+
fs.realpathSync = realpathSync
|
61
|
+
}
|
62
|
+
|
63
|
+
function unmonkeypatch () {
|
64
|
+
fs.realpath = origRealpath
|
65
|
+
fs.realpathSync = origRealpathSync
|
66
|
+
}
|
@@ -0,0 +1,303 @@
|
|
1
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
2
|
+
//
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
// copy of this software and associated documentation files (the
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
// persons to whom the Software is furnished to do so, subject to the
|
9
|
+
// following conditions:
|
10
|
+
//
|
11
|
+
// The above copyright notice and this permission notice shall be included
|
12
|
+
// in all copies or substantial portions of the Software.
|
13
|
+
//
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
17
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
18
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
19
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
20
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
var pathModule = require('path');
|
23
|
+
var isWindows = process.platform === 'win32';
|
24
|
+
var fs = require('fs');
|
25
|
+
|
26
|
+
// JavaScript implementation of realpath, ported from node pre-v6
|
27
|
+
|
28
|
+
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
29
|
+
|
30
|
+
function rethrow() {
|
31
|
+
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
|
32
|
+
// is fairly slow to generate.
|
33
|
+
var callback;
|
34
|
+
if (DEBUG) {
|
35
|
+
var backtrace = new Error;
|
36
|
+
callback = debugCallback;
|
37
|
+
} else
|
38
|
+
callback = missingCallback;
|
39
|
+
|
40
|
+
return callback;
|
41
|
+
|
42
|
+
function debugCallback(err) {
|
43
|
+
if (err) {
|
44
|
+
backtrace.message = err.message;
|
45
|
+
err = backtrace;
|
46
|
+
missingCallback(err);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
function missingCallback(err) {
|
51
|
+
if (err) {
|
52
|
+
if (process.throwDeprecation)
|
53
|
+
throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
|
54
|
+
else if (!process.noDeprecation) {
|
55
|
+
var msg = 'fs: missing callback ' + (err.stack || err.message);
|
56
|
+
if (process.traceDeprecation)
|
57
|
+
console.trace(msg);
|
58
|
+
else
|
59
|
+
console.error(msg);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
function maybeCallback(cb) {
|
66
|
+
return typeof cb === 'function' ? cb : rethrow();
|
67
|
+
}
|
68
|
+
|
69
|
+
var normalize = pathModule.normalize;
|
70
|
+
|
71
|
+
// Regexp that finds the next partion of a (partial) path
|
72
|
+
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
73
|
+
if (isWindows) {
|
74
|
+
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
75
|
+
} else {
|
76
|
+
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
77
|
+
}
|
78
|
+
|
79
|
+
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
80
|
+
if (isWindows) {
|
81
|
+
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
82
|
+
} else {
|
83
|
+
var splitRootRe = /^[\/]*/;
|
84
|
+
}
|
85
|
+
|
86
|
+
exports.realpathSync = function realpathSync(p, cache) {
|
87
|
+
// make p is absolute
|
88
|
+
p = pathModule.resolve(p);
|
89
|
+
|
90
|
+
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
91
|
+
return cache[p];
|
92
|
+
}
|
93
|
+
|
94
|
+
var original = p,
|
95
|
+
seenLinks = {},
|
96
|
+
knownHard = {};
|
97
|
+
|
98
|
+
// current character position in p
|
99
|
+
var pos;
|
100
|
+
// the partial path so far, including a trailing slash if any
|
101
|
+
var current;
|
102
|
+
// the partial path without a trailing slash (except when pointing at a root)
|
103
|
+
var base;
|
104
|
+
// the partial path scanned in the previous round, with slash
|
105
|
+
var previous;
|
106
|
+
|
107
|
+
start();
|
108
|
+
|
109
|
+
function start() {
|
110
|
+
// Skip over roots
|
111
|
+
var m = splitRootRe.exec(p);
|
112
|
+
pos = m[0].length;
|
113
|
+
current = m[0];
|
114
|
+
base = m[0];
|
115
|
+
previous = '';
|
116
|
+
|
117
|
+
// On windows, check that the root exists. On unix there is no need.
|
118
|
+
if (isWindows && !knownHard[base]) {
|
119
|
+
fs.lstatSync(base);
|
120
|
+
knownHard[base] = true;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
// walk down the path, swapping out linked pathparts for their real
|
125
|
+
// values
|
126
|
+
// NB: p.length changes.
|
127
|
+
while (pos < p.length) {
|
128
|
+
// find the next part
|
129
|
+
nextPartRe.lastIndex = pos;
|
130
|
+
var result = nextPartRe.exec(p);
|
131
|
+
previous = current;
|
132
|
+
current += result[0];
|
133
|
+
base = previous + result[1];
|
134
|
+
pos = nextPartRe.lastIndex;
|
135
|
+
|
136
|
+
// continue if not a symlink
|
137
|
+
if (knownHard[base] || (cache && cache[base] === base)) {
|
138
|
+
continue;
|
139
|
+
}
|
140
|
+
|
141
|
+
var resolvedLink;
|
142
|
+
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
143
|
+
// some known symbolic link. no need to stat again.
|
144
|
+
resolvedLink = cache[base];
|
145
|
+
} else {
|
146
|
+
var stat = fs.lstatSync(base);
|
147
|
+
if (!stat.isSymbolicLink()) {
|
148
|
+
knownHard[base] = true;
|
149
|
+
if (cache) cache[base] = base;
|
150
|
+
continue;
|
151
|
+
}
|
152
|
+
|
153
|
+
// read the link if it wasn't read before
|
154
|
+
// dev/ino always return 0 on windows, so skip the check.
|
155
|
+
var linkTarget = null;
|
156
|
+
if (!isWindows) {
|
157
|
+
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
158
|
+
if (seenLinks.hasOwnProperty(id)) {
|
159
|
+
linkTarget = seenLinks[id];
|
160
|
+
}
|
161
|
+
}
|
162
|
+
if (linkTarget === null) {
|
163
|
+
fs.statSync(base);
|
164
|
+
linkTarget = fs.readlinkSync(base);
|
165
|
+
}
|
166
|
+
resolvedLink = pathModule.resolve(previous, linkTarget);
|
167
|
+
// track this, if given a cache.
|
168
|
+
if (cache) cache[base] = resolvedLink;
|
169
|
+
if (!isWindows) seenLinks[id] = linkTarget;
|
170
|
+
}
|
171
|
+
|
172
|
+
// resolve the link, then start over
|
173
|
+
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
174
|
+
start();
|
175
|
+
}
|
176
|
+
|
177
|
+
if (cache) cache[original] = p;
|
178
|
+
|
179
|
+
return p;
|
180
|
+
};
|
181
|
+
|
182
|
+
|
183
|
+
exports.realpath = function realpath(p, cache, cb) {
|
184
|
+
if (typeof cb !== 'function') {
|
185
|
+
cb = maybeCallback(cache);
|
186
|
+
cache = null;
|
187
|
+
}
|
188
|
+
|
189
|
+
// make p is absolute
|
190
|
+
p = pathModule.resolve(p);
|
191
|
+
|
192
|
+
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
193
|
+
return process.nextTick(cb.bind(null, null, cache[p]));
|
194
|
+
}
|
195
|
+
|
196
|
+
var original = p,
|
197
|
+
seenLinks = {},
|
198
|
+
knownHard = {};
|
199
|
+
|
200
|
+
// current character position in p
|
201
|
+
var pos;
|
202
|
+
// the partial path so far, including a trailing slash if any
|
203
|
+
var current;
|
204
|
+
// the partial path without a trailing slash (except when pointing at a root)
|
205
|
+
var base;
|
206
|
+
// the partial path scanned in the previous round, with slash
|
207
|
+
var previous;
|
208
|
+
|
209
|
+
start();
|
210
|
+
|
211
|
+
function start() {
|
212
|
+
// Skip over roots
|
213
|
+
var m = splitRootRe.exec(p);
|
214
|
+
pos = m[0].length;
|
215
|
+
current = m[0];
|
216
|
+
base = m[0];
|
217
|
+
previous = '';
|
218
|
+
|
219
|
+
// On windows, check that the root exists. On unix there is no need.
|
220
|
+
if (isWindows && !knownHard[base]) {
|
221
|
+
fs.lstat(base, function(err) {
|
222
|
+
if (err) return cb(err);
|
223
|
+
knownHard[base] = true;
|
224
|
+
LOOP();
|
225
|
+
});
|
226
|
+
} else {
|
227
|
+
process.nextTick(LOOP);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
// walk down the path, swapping out linked pathparts for their real
|
232
|
+
// values
|
233
|
+
function LOOP() {
|
234
|
+
// stop if scanned past end of path
|
235
|
+
if (pos >= p.length) {
|
236
|
+
if (cache) cache[original] = p;
|
237
|
+
return cb(null, p);
|
238
|
+
}
|
239
|
+
|
240
|
+
// find the next part
|
241
|
+
nextPartRe.lastIndex = pos;
|
242
|
+
var result = nextPartRe.exec(p);
|
243
|
+
previous = current;
|
244
|
+
current += result[0];
|
245
|
+
base = previous + result[1];
|
246
|
+
pos = nextPartRe.lastIndex;
|
247
|
+
|
248
|
+
// continue if not a symlink
|
249
|
+
if (knownHard[base] || (cache && cache[base] === base)) {
|
250
|
+
return process.nextTick(LOOP);
|
251
|
+
}
|
252
|
+
|
253
|
+
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
254
|
+
// known symbolic link. no need to stat again.
|
255
|
+
return gotResolvedLink(cache[base]);
|
256
|
+
}
|
257
|
+
|
258
|
+
return fs.lstat(base, gotStat);
|
259
|
+
}
|
260
|
+
|
261
|
+
function gotStat(err, stat) {
|
262
|
+
if (err) return cb(err);
|
263
|
+
|
264
|
+
// if not a symlink, skip to the next path part
|
265
|
+
if (!stat.isSymbolicLink()) {
|
266
|
+
knownHard[base] = true;
|
267
|
+
if (cache) cache[base] = base;
|
268
|
+
return process.nextTick(LOOP);
|
269
|
+
}
|
270
|
+
|
271
|
+
// stat & read the link if not read before
|
272
|
+
// call gotTarget as soon as the link target is known
|
273
|
+
// dev/ino always return 0 on windows, so skip the check.
|
274
|
+
if (!isWindows) {
|
275
|
+
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
276
|
+
if (seenLinks.hasOwnProperty(id)) {
|
277
|
+
return gotTarget(null, seenLinks[id], base);
|
278
|
+
}
|
279
|
+
}
|
280
|
+
fs.stat(base, function(err) {
|
281
|
+
if (err) return cb(err);
|
282
|
+
|
283
|
+
fs.readlink(base, function(err, target) {
|
284
|
+
if (!isWindows) seenLinks[id] = target;
|
285
|
+
gotTarget(err, target);
|
286
|
+
});
|
287
|
+
});
|
288
|
+
}
|
289
|
+
|
290
|
+
function gotTarget(err, target, base) {
|
291
|
+
if (err) return cb(err);
|
292
|
+
|
293
|
+
var resolvedLink = pathModule.resolve(previous, target);
|
294
|
+
if (cache) cache[base] = resolvedLink;
|
295
|
+
gotResolvedLink(resolvedLink);
|
296
|
+
}
|
297
|
+
|
298
|
+
function gotResolvedLink(resolvedLink) {
|
299
|
+
// resolve the link, then start over
|
300
|
+
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
301
|
+
start();
|
302
|
+
}
|
303
|
+
};
|