autobench 0.0.1alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +16 -0
- data/README.md +123 -0
- data/bin/autobench +180 -0
- data/bin/autobench-config +162 -0
- data/lib/autobench.rb +28 -0
- data/lib/autobench/client.rb +78 -0
- data/lib/autobench/common.rb +49 -0
- data/lib/autobench/config.rb +62 -0
- data/lib/autobench/render.rb +102 -0
- data/lib/autobench/version.rb +3 -0
- data/lib/autobench/yslow.rb +75 -0
- data/lib/phantomas/README.md +296 -0
- data/lib/phantomas/core/formatter.js +65 -0
- data/lib/phantomas/core/helper.js +64 -0
- data/lib/phantomas/core/modules/requestsMonitor/requestsMonitor.js +214 -0
- data/lib/phantomas/core/pads.js +16 -0
- data/lib/phantomas/core/phantomas.js +418 -0
- data/lib/phantomas/lib/args.js +27 -0
- data/lib/phantomas/lib/modules/_coffee-script.js +2 -0
- data/lib/phantomas/lib/modules/assert.js +326 -0
- data/lib/phantomas/lib/modules/events.js +216 -0
- data/lib/phantomas/lib/modules/http.js +55 -0
- data/lib/phantomas/lib/modules/path.js +441 -0
- data/lib/phantomas/lib/modules/punycode.js +510 -0
- data/lib/phantomas/lib/modules/querystring.js +214 -0
- data/lib/phantomas/lib/modules/tty.js +7 -0
- data/lib/phantomas/lib/modules/url.js +625 -0
- data/lib/phantomas/lib/modules/util.js +520 -0
- data/lib/phantomas/modules/ajaxRequests/ajaxRequests.js +15 -0
- data/lib/phantomas/modules/assetsTypes/assetsTypes.js +21 -0
- data/lib/phantomas/modules/cacheHits/cacheHits.js +28 -0
- data/lib/phantomas/modules/caching/caching.js +66 -0
- data/lib/phantomas/modules/cookies/cookies.js +54 -0
- data/lib/phantomas/modules/domComplexity/domComplexity.js +130 -0
- data/lib/phantomas/modules/domQueries/domQueries.js +148 -0
- data/lib/phantomas/modules/domains/domains.js +49 -0
- data/lib/phantomas/modules/globalVariables/globalVariables.js +44 -0
- data/lib/phantomas/modules/headers/headers.js +48 -0
- data/lib/phantomas/modules/localStorage/localStorage.js +14 -0
- data/lib/phantomas/modules/requestsStats/requestsStats.js +71 -0
- data/lib/phantomas/modules/staticAssets/staticAssets.js +40 -0
- data/lib/phantomas/modules/waterfall/waterfall.js +62 -0
- data/lib/phantomas/modules/windowPerformance/windowPerformance.js +36 -0
- data/lib/phantomas/package.json +27 -0
- data/lib/phantomas/phantomas.js +35 -0
- data/lib/phantomas/run-multiple.js +177 -0
- data/lib/yslow.js +5 -0
- metadata +135 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
exports.STATUS_CODES = {
|
2
|
+
'100': 'Continue',
|
3
|
+
'101': 'Switching Protocols',
|
4
|
+
'102': 'Processing',
|
5
|
+
'200': 'OK',
|
6
|
+
'201': 'Created',
|
7
|
+
'202': 'Accepted',
|
8
|
+
'203': 'Non-Authoritative Information',
|
9
|
+
'204': 'No Content',
|
10
|
+
'205': 'Reset Content',
|
11
|
+
'206': 'Partial Content',
|
12
|
+
'207': 'Multi-Status',
|
13
|
+
'300': 'Multiple Choices',
|
14
|
+
'301': 'Moved Permanently',
|
15
|
+
'302': 'Moved Temporarily',
|
16
|
+
'303': 'See Other',
|
17
|
+
'304': 'Not Modified',
|
18
|
+
'305': 'Use Proxy',
|
19
|
+
'307': 'Temporary Redirect',
|
20
|
+
'400': 'Bad Request',
|
21
|
+
'401': 'Unauthorized',
|
22
|
+
'402': 'Payment Required',
|
23
|
+
'403': 'Forbidden',
|
24
|
+
'404': 'Not Found',
|
25
|
+
'405': 'Method Not Allowed',
|
26
|
+
'406': 'Not Acceptable',
|
27
|
+
'407': 'Proxy Authentication Required',
|
28
|
+
'408': 'Request Time-out',
|
29
|
+
'409': 'Conflict',
|
30
|
+
'410': 'Gone',
|
31
|
+
'411': 'Length Required',
|
32
|
+
'412': 'Precondition Failed',
|
33
|
+
'413': 'Request Entity Too Large',
|
34
|
+
'414': 'Request-URI Too Large',
|
35
|
+
'415': 'Unsupported Media Type',
|
36
|
+
'416': 'Requested Range Not Satisfiable',
|
37
|
+
'417': 'Expectation Failed',
|
38
|
+
'418': 'I\'m a teapot',
|
39
|
+
'422': 'Unprocessable Entity',
|
40
|
+
'423': 'Locked',
|
41
|
+
'424': 'Failed Dependency',
|
42
|
+
'425': 'Unordered Collection',
|
43
|
+
'426': 'Upgrade Required',
|
44
|
+
'500': 'Internal Server Error',
|
45
|
+
'501': 'Not Implemented',
|
46
|
+
'502': 'Bad Gateway',
|
47
|
+
'503': 'Service Unavailable',
|
48
|
+
'504': 'Gateway Time-out',
|
49
|
+
'505': 'HTTP Version not supported',
|
50
|
+
'506': 'Variant Also Negotiates',
|
51
|
+
'507': 'Insufficient Storage',
|
52
|
+
'509': 'Bandwidth Limit Exceeded',
|
53
|
+
'510': 'Not Extended'
|
54
|
+
};
|
55
|
+
|
@@ -0,0 +1,441 @@
|
|
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
|
+
|
23
|
+
var isWindows = process.platform === 'win32';
|
24
|
+
|
25
|
+
|
26
|
+
// resolves . and .. elements in a path array with directory names there
|
27
|
+
// must be no slashes, empty elements, or device names (c:\) in the array
|
28
|
+
// (so also no leading and trailing slashes - it does not distinguish
|
29
|
+
// relative and absolute paths)
|
30
|
+
function normalizeArray(parts, allowAboveRoot) {
|
31
|
+
// if the path tries to go above the root, `up` ends up > 0
|
32
|
+
var up = 0;
|
33
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
34
|
+
var last = parts[i];
|
35
|
+
if (last == '.') {
|
36
|
+
parts.splice(i, 1);
|
37
|
+
} else if (last === '..') {
|
38
|
+
parts.splice(i, 1);
|
39
|
+
up++;
|
40
|
+
} else if (up) {
|
41
|
+
parts.splice(i, 1);
|
42
|
+
up--;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
// if the path is allowed to go above the root, restore leading ..s
|
47
|
+
if (allowAboveRoot) {
|
48
|
+
for (; up--; up) {
|
49
|
+
parts.unshift('..');
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
return parts;
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
if (isWindows) {
|
58
|
+
// Regex to split a windows path into three parts: [*, device, slash,
|
59
|
+
// tail] windows-only
|
60
|
+
var splitDeviceRe =
|
61
|
+
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
62
|
+
|
63
|
+
// Regex to split the tail part of the above into [*, dir, basename, ext]
|
64
|
+
var splitTailRe = /^([\s\S]+[\\\/](?!$)|[\\\/])?((?:[\s\S]+?)?(\.[^.]*)?)$/;
|
65
|
+
|
66
|
+
// Function to split a filename into [root, dir, basename, ext]
|
67
|
+
// windows version
|
68
|
+
var splitPath = function(filename) {
|
69
|
+
// Separate device+slash from tail
|
70
|
+
var result = splitDeviceRe.exec(filename),
|
71
|
+
device = (result[1] || '') + (result[2] || ''),
|
72
|
+
tail = result[3] || '';
|
73
|
+
// Split the tail into dir, basename and extension
|
74
|
+
var result2 = splitTailRe.exec(tail),
|
75
|
+
dir = result2[1] || '',
|
76
|
+
basename = result2[2] || '',
|
77
|
+
ext = result2[3] || '';
|
78
|
+
return [device, dir, basename, ext];
|
79
|
+
};
|
80
|
+
|
81
|
+
// path.resolve([from ...], to)
|
82
|
+
// windows version
|
83
|
+
exports.resolve = function() {
|
84
|
+
var resolvedDevice = '',
|
85
|
+
resolvedTail = '',
|
86
|
+
resolvedAbsolute = false;
|
87
|
+
|
88
|
+
for (var i = arguments.length - 1; i >= -1; i--) {
|
89
|
+
var path;
|
90
|
+
if (i >= 0) {
|
91
|
+
path = arguments[i];
|
92
|
+
} else if (!resolvedDevice) {
|
93
|
+
path = process.cwd();
|
94
|
+
} else {
|
95
|
+
// Windows has the concept of drive-specific current working
|
96
|
+
// directories. If we've resolved a drive letter but not yet an
|
97
|
+
// absolute path, get cwd for that drive. We're sure the device is not
|
98
|
+
// an unc path at this points, because unc paths are always absolute.
|
99
|
+
path = process._cwdForDrive(resolvedDevice[0]);
|
100
|
+
}
|
101
|
+
|
102
|
+
// Skip empty and invalid entries
|
103
|
+
if (typeof path !== 'string' || !path) {
|
104
|
+
continue;
|
105
|
+
}
|
106
|
+
|
107
|
+
var result = splitDeviceRe.exec(path),
|
108
|
+
device = result[1] || '',
|
109
|
+
isUnc = device && device.charAt(1) !== ':',
|
110
|
+
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
|
111
|
+
tail = result[3];
|
112
|
+
|
113
|
+
if (device &&
|
114
|
+
resolvedDevice &&
|
115
|
+
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
116
|
+
// This path points to another device so it is not applicable
|
117
|
+
continue;
|
118
|
+
}
|
119
|
+
|
120
|
+
if (!resolvedDevice) {
|
121
|
+
resolvedDevice = device;
|
122
|
+
}
|
123
|
+
if (!resolvedAbsolute) {
|
124
|
+
resolvedTail = tail + '\\' + resolvedTail;
|
125
|
+
resolvedAbsolute = isAbsolute;
|
126
|
+
}
|
127
|
+
|
128
|
+
if (resolvedDevice && resolvedAbsolute) {
|
129
|
+
break;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
// Replace slashes (in UNC share name) by backslashes
|
134
|
+
resolvedDevice = resolvedDevice.replace(/\//g, '\\');
|
135
|
+
|
136
|
+
// At this point the path should be resolved to a full absolute path,
|
137
|
+
// but handle relative paths to be safe (might happen when process.cwd()
|
138
|
+
// fails)
|
139
|
+
|
140
|
+
// Normalize the tail path
|
141
|
+
|
142
|
+
function f(p) {
|
143
|
+
return !!p;
|
144
|
+
}
|
145
|
+
|
146
|
+
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
|
147
|
+
!resolvedAbsolute).join('\\');
|
148
|
+
|
149
|
+
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
|
150
|
+
'.';
|
151
|
+
};
|
152
|
+
|
153
|
+
// windows version
|
154
|
+
exports.normalize = function(path) {
|
155
|
+
var result = splitDeviceRe.exec(path),
|
156
|
+
device = result[1] || '',
|
157
|
+
isUnc = device && device.charAt(1) !== ':',
|
158
|
+
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
|
159
|
+
tail = result[3],
|
160
|
+
trailingSlash = /[\\\/]$/.test(tail);
|
161
|
+
|
162
|
+
// Normalize the tail path
|
163
|
+
tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) {
|
164
|
+
return !!p;
|
165
|
+
}), !isAbsolute).join('\\');
|
166
|
+
|
167
|
+
if (!tail && !isAbsolute) {
|
168
|
+
tail = '.';
|
169
|
+
}
|
170
|
+
if (tail && trailingSlash) {
|
171
|
+
tail += '\\';
|
172
|
+
}
|
173
|
+
|
174
|
+
return device + (isAbsolute ? '\\' : '') + tail;
|
175
|
+
};
|
176
|
+
|
177
|
+
// windows version
|
178
|
+
exports.join = function() {
|
179
|
+
function f(p) {
|
180
|
+
return p && typeof p === 'string';
|
181
|
+
}
|
182
|
+
|
183
|
+
var paths = Array.prototype.slice.call(arguments, 0).filter(f);
|
184
|
+
var joined = paths.join('\\');
|
185
|
+
|
186
|
+
// Make sure that the joined path doesn't start with two slashes
|
187
|
+
// - it will be mistaken for an unc path by normalize() -
|
188
|
+
// unless the paths[0] also starts with two slashes
|
189
|
+
if (/^[\\\/]{2}/.test(joined) && !/^[\\\/]{2}/.test(paths[0])) {
|
190
|
+
joined = joined.slice(1);
|
191
|
+
}
|
192
|
+
|
193
|
+
return exports.normalize(joined);
|
194
|
+
};
|
195
|
+
|
196
|
+
// path.relative(from, to)
|
197
|
+
// it will solve the relative path from 'from' to 'to', for instance:
|
198
|
+
// from = 'C:\\orandea\\test\\aaa'
|
199
|
+
// to = 'C:\\orandea\\impl\\bbb'
|
200
|
+
// The output of the function should be: '..\\..\\impl\\bbb'
|
201
|
+
// windows version
|
202
|
+
exports.relative = function(from, to) {
|
203
|
+
from = exports.resolve(from);
|
204
|
+
to = exports.resolve(to);
|
205
|
+
|
206
|
+
// windows is not case sensitive
|
207
|
+
var lowerFrom = from.toLowerCase();
|
208
|
+
var lowerTo = to.toLowerCase();
|
209
|
+
|
210
|
+
function trim(arr) {
|
211
|
+
var start = 0;
|
212
|
+
for (; start < arr.length; start++) {
|
213
|
+
if (arr[start] !== '') break;
|
214
|
+
}
|
215
|
+
|
216
|
+
var end = arr.length - 1;
|
217
|
+
for (; end >= 0; end--) {
|
218
|
+
if (arr[end] !== '') break;
|
219
|
+
}
|
220
|
+
|
221
|
+
if (start > end) return [];
|
222
|
+
return arr.slice(start, end - start + 1);
|
223
|
+
}
|
224
|
+
|
225
|
+
var fromParts = trim(from.split('\\'));
|
226
|
+
var toParts = trim(to.split('\\'));
|
227
|
+
|
228
|
+
var lowerFromParts = trim(lowerFrom.split('\\'));
|
229
|
+
var lowerToParts = trim(lowerTo.split('\\'));
|
230
|
+
|
231
|
+
var length = Math.min(lowerFromParts.length, lowerToParts.length);
|
232
|
+
var samePartsLength = length;
|
233
|
+
for (var i = 0; i < length; i++) {
|
234
|
+
if (lowerFromParts[i] !== lowerToParts[i]) {
|
235
|
+
samePartsLength = i;
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
if (samePartsLength == 0) {
|
241
|
+
return to;
|
242
|
+
}
|
243
|
+
|
244
|
+
var outputParts = [];
|
245
|
+
for (var i = samePartsLength; i < lowerFromParts.length; i++) {
|
246
|
+
outputParts.push('..');
|
247
|
+
}
|
248
|
+
|
249
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
250
|
+
|
251
|
+
return outputParts.join('\\');
|
252
|
+
};
|
253
|
+
|
254
|
+
|
255
|
+
} else /* posix */ {
|
256
|
+
|
257
|
+
// Split a filename into [root, dir, basename, ext], unix version
|
258
|
+
// 'root' is just a slash, or nothing.
|
259
|
+
var splitPathRe = /^(\/?)([\s\S]+\/(?!$)|\/)?((?:[\s\S]+?)?(\.[^.]*)?)$/;
|
260
|
+
var splitPath = function(filename) {
|
261
|
+
var result = splitPathRe.exec(filename);
|
262
|
+
return [result[1] || '', result[2] || '', result[3] || '', result[4] || ''];
|
263
|
+
};
|
264
|
+
|
265
|
+
// path.resolve([from ...], to)
|
266
|
+
// posix version
|
267
|
+
exports.resolve = function() {
|
268
|
+
var resolvedPath = '',
|
269
|
+
resolvedAbsolute = false;
|
270
|
+
|
271
|
+
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
272
|
+
var path = (i >= 0) ? arguments[i] : process.cwd();
|
273
|
+
|
274
|
+
// Skip empty and invalid entries
|
275
|
+
if (typeof path !== 'string' || !path) {
|
276
|
+
continue;
|
277
|
+
}
|
278
|
+
|
279
|
+
resolvedPath = path + '/' + resolvedPath;
|
280
|
+
resolvedAbsolute = path.charAt(0) === '/';
|
281
|
+
}
|
282
|
+
|
283
|
+
// At this point the path should be resolved to a full absolute path, but
|
284
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
285
|
+
|
286
|
+
// Normalize the path
|
287
|
+
resolvedPath = normalizeArray(resolvedPath.split('/').filter(function(p) {
|
288
|
+
return !!p;
|
289
|
+
}), !resolvedAbsolute).join('/');
|
290
|
+
|
291
|
+
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
292
|
+
};
|
293
|
+
|
294
|
+
// path.normalize(path)
|
295
|
+
// posix version
|
296
|
+
exports.normalize = function(path) {
|
297
|
+
var isAbsolute = path.charAt(0) === '/',
|
298
|
+
trailingSlash = path.slice(-1) === '/';
|
299
|
+
|
300
|
+
// Normalize the path
|
301
|
+
path = normalizeArray(path.split('/').filter(function(p) {
|
302
|
+
return !!p;
|
303
|
+
}), !isAbsolute).join('/');
|
304
|
+
|
305
|
+
if (!path && !isAbsolute) {
|
306
|
+
path = '.';
|
307
|
+
}
|
308
|
+
if (path && trailingSlash) {
|
309
|
+
path += '/';
|
310
|
+
}
|
311
|
+
|
312
|
+
return (isAbsolute ? '/' : '') + path;
|
313
|
+
};
|
314
|
+
|
315
|
+
|
316
|
+
// posix version
|
317
|
+
exports.join = function() {
|
318
|
+
var paths = Array.prototype.slice.call(arguments, 0);
|
319
|
+
return exports.normalize(paths.filter(function(p, index) {
|
320
|
+
return p && typeof p === 'string';
|
321
|
+
}).join('/'));
|
322
|
+
};
|
323
|
+
|
324
|
+
|
325
|
+
// path.relative(from, to)
|
326
|
+
// posix version
|
327
|
+
exports.relative = function(from, to) {
|
328
|
+
from = exports.resolve(from).substr(1);
|
329
|
+
to = exports.resolve(to).substr(1);
|
330
|
+
|
331
|
+
function trim(arr) {
|
332
|
+
var start = 0;
|
333
|
+
for (; start < arr.length; start++) {
|
334
|
+
if (arr[start] !== '') break;
|
335
|
+
}
|
336
|
+
|
337
|
+
var end = arr.length - 1;
|
338
|
+
for (; end >= 0; end--) {
|
339
|
+
if (arr[end] !== '') break;
|
340
|
+
}
|
341
|
+
|
342
|
+
if (start > end) return [];
|
343
|
+
return arr.slice(start, end - start + 1);
|
344
|
+
}
|
345
|
+
|
346
|
+
var fromParts = trim(from.split('/'));
|
347
|
+
var toParts = trim(to.split('/'));
|
348
|
+
|
349
|
+
var length = Math.min(fromParts.length, toParts.length);
|
350
|
+
var samePartsLength = length;
|
351
|
+
for (var i = 0; i < length; i++) {
|
352
|
+
if (fromParts[i] !== toParts[i]) {
|
353
|
+
samePartsLength = i;
|
354
|
+
break;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
var outputParts = [];
|
359
|
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
360
|
+
outputParts.push('..');
|
361
|
+
}
|
362
|
+
|
363
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
364
|
+
|
365
|
+
return outputParts.join('/');
|
366
|
+
};
|
367
|
+
|
368
|
+
}
|
369
|
+
|
370
|
+
|
371
|
+
exports.dirname = function(path) {
|
372
|
+
var result = splitPath(path),
|
373
|
+
root = result[0],
|
374
|
+
dir = result[1];
|
375
|
+
|
376
|
+
if (!root && !dir) {
|
377
|
+
// No dirname whatsoever
|
378
|
+
return '.';
|
379
|
+
}
|
380
|
+
|
381
|
+
if (dir) {
|
382
|
+
// It has a dirname, strip trailing slash
|
383
|
+
dir = dir.substring(0, dir.length - 1);
|
384
|
+
}
|
385
|
+
|
386
|
+
return root + dir;
|
387
|
+
};
|
388
|
+
|
389
|
+
|
390
|
+
exports.basename = function(path, ext) {
|
391
|
+
var f = splitPath(path)[2];
|
392
|
+
// TODO: make this comparison case-insensitive on windows?
|
393
|
+
if (ext && f.substr(-1 * ext.length) === ext) {
|
394
|
+
f = f.substr(0, f.length - ext.length);
|
395
|
+
}
|
396
|
+
return f;
|
397
|
+
};
|
398
|
+
|
399
|
+
|
400
|
+
exports.extname = function(path) {
|
401
|
+
return splitPath(path)[3];
|
402
|
+
};
|
403
|
+
|
404
|
+
|
405
|
+
exports.exists = function(path, callback) {
|
406
|
+
process.binding('fs').stat(path, function(err, stats) {
|
407
|
+
if (callback) callback(err ? false : true);
|
408
|
+
});
|
409
|
+
};
|
410
|
+
|
411
|
+
|
412
|
+
exports.existsSync = function(path) {
|
413
|
+
try {
|
414
|
+
process.binding('fs').stat(path);
|
415
|
+
return true;
|
416
|
+
} catch (e) {
|
417
|
+
return false;
|
418
|
+
}
|
419
|
+
};
|
420
|
+
|
421
|
+
|
422
|
+
exports._makeLong = isWindows ?
|
423
|
+
function(path) {
|
424
|
+
var resolvedPath = exports.resolve(path);
|
425
|
+
|
426
|
+
if (resolvedPath.match(/^[a-zA-Z]\:\\/)) {
|
427
|
+
// path is local filesystem path, which needs to be converted
|
428
|
+
// to long UNC path.
|
429
|
+
return '\\\\?\\' + resolvedPath;
|
430
|
+
} else if (resolvedPath.match(/^\\\\[^?.]/)) {
|
431
|
+
// path is network UNC path, which needs to be converted
|
432
|
+
// to long UNC path.
|
433
|
+
return '\\\\?\\UNC\\' + resolvedPath.substring(2);
|
434
|
+
}
|
435
|
+
|
436
|
+
return path;
|
437
|
+
} :
|
438
|
+
function(path) {
|
439
|
+
return path;
|
440
|
+
};
|
441
|
+
|