You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
401 lines
11 KiB
401 lines
11 KiB
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Code coverage report for tar/lib/extract.js</title>
|
|
<meta charset="utf-8" />
|
|
<link rel="stylesheet" href="../../prettify.css" />
|
|
<link rel="stylesheet" href="../../base.css" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<style type='text/css'>
|
|
.coverage-summary .sorter {
|
|
background-image: url(../../sort-arrow-sprite.png);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class='wrapper'>
|
|
<div class='pad1'>
|
|
<h1>
|
|
<a href="../../index.html">All files</a> / <a href="index.html">tar/lib</a> extract.js
|
|
</h1>
|
|
<div class='clearfix'>
|
|
<div class='fl pad1y space-right2'>
|
|
<span class="strong">100% </span>
|
|
<span class="quiet">Statements</span>
|
|
<span class='fraction'>61/61</span>
|
|
</div>
|
|
<div class='fl pad1y space-right2'>
|
|
<span class="strong">100% </span>
|
|
<span class="quiet">Branches</span>
|
|
<span class='fraction'>45/45</span>
|
|
</div>
|
|
<div class='fl pad1y space-right2'>
|
|
<span class="strong">100% </span>
|
|
<span class="quiet">Functions</span>
|
|
<span class='fraction'>12/12</span>
|
|
</div>
|
|
<div class='fl pad1y space-right2'>
|
|
<span class="strong">100% </span>
|
|
<span class="quiet">Lines</span>
|
|
<span class='fraction'>60/60</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class='status-line high'></div>
|
|
<pre><table class="coverage">
|
|
<tr><td class="line-count quiet">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
|
|
76
|
|
77
|
|
78
|
|
79
|
|
80
|
|
81
|
|
82
|
|
83
|
|
84
|
|
85
|
|
86
|
|
87
|
|
88
|
|
89
|
|
90
|
|
91
|
|
92
|
|
93
|
|
94
|
|
95
|
|
96
|
|
97
|
|
98
|
|
99
|
|
100
|
|
101
|
|
102
|
|
103
|
|
104
|
|
105
|
|
106
|
|
107
|
|
108
|
|
109
|
|
110
|
|
111
|
|
112
|
|
113</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">21x</span>
|
|
<span class="cline-any cline-yes">1x</span>
|
|
<span class="cline-any cline-yes">20x</span>
|
|
<span class="cline-any cline-yes">1x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">21x</span>
|
|
<span class="cline-any cline-yes">3x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">21x</span>
|
|
<span class="cline-any cline-yes">13x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">8x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">21x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">21x</span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">19x</span>
|
|
<span class="cline-any cline-yes">1x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">18x</span>
|
|
<span class="cline-any cline-yes">7x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">18x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">13x</span>
|
|
<span class="cline-any cline-yes">7x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">7x</span>
|
|
<span class="cline-any cline-yes">87x</span>
|
|
<span class="cline-any cline-yes">87x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">87x</span>
|
|
<span class="cline-any cline-yes">87x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">7x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">6x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">6x</span>
|
|
<span class="cline-any cline-yes">6x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">6x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">5x</span>
|
|
<span class="cline-any cline-yes">5x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">4x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-yes">1x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">8x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">8x</span>
|
|
<span class="cline-any cline-yes">8x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">9x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">1x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-yes">2x</span>
|
|
<span class="cline-any cline-neutral"> </span>
|
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict'
|
|
|
|
// tar -x
|
|
const hlo = require('./high-level-opt.js')
|
|
const Unpack = require('./unpack.js')
|
|
const fs = require('fs')
|
|
const fsm = require('fs-minipass')
|
|
const path = require('path')
|
|
|
|
const x = module.exports = (opt_, files, cb) => {
|
|
if (typeof opt_ === 'function')
|
|
cb = opt_, files = null, opt_ = {}
|
|
else if (Array.isArray(opt_))
|
|
files = opt_, opt_ = {}
|
|
|
|
if (typeof files === 'function')
|
|
cb = files, files = null
|
|
|
|
if (!files)
|
|
files = []
|
|
else
|
|
files = Array.from(files)
|
|
|
|
const opt = hlo(opt_)
|
|
|
|
if (opt.sync && typeof cb === 'function')
|
|
throw new TypeError('callback not supported for sync tar functions')
|
|
|
|
if (!opt.file && typeof cb === 'function')
|
|
throw new TypeError('callback only supported with file option')
|
|
|
|
if (files.length)
|
|
filesFilter(opt, files)
|
|
|
|
return opt.file && opt.sync ? extractFileSync(opt)
|
|
: opt.file ? extractFile(opt, cb)
|
|
: opt.sync ? extractSync(opt)
|
|
: extract(opt)
|
|
}
|
|
|
|
// construct a filter that limits the file entries listed
|
|
// include child entries if a dir is included
|
|
const filesFilter = (opt, files) => {
|
|
const map = new Map(files.map(f => [f.replace(/\/+$/, ''), true]))
|
|
const filter = opt.filter
|
|
|
|
const mapHas = (file, r) => {
|
|
const root = r || path.parse(file).root || '.'
|
|
const ret = file === root ? false
|
|
: map.has(file) ? map.get(file)
|
|
: mapHas(path.dirname(file), root)
|
|
|
|
map.set(file, ret)
|
|
return ret
|
|
}
|
|
|
|
opt.filter = filter
|
|
? (file, entry) => filter(file, entry) && mapHas(file.replace(/\/+$/, ''))
|
|
: file => mapHas(file.replace(/\/+$/, ''))
|
|
}
|
|
|
|
const extractFileSync = opt => {
|
|
const u = new Unpack.Sync(opt)
|
|
|
|
const file = opt.file
|
|
let threw = true
|
|
let fd
|
|
const stat = fs.statSync(file)
|
|
// This trades a zero-byte read() syscall for a stat
|
|
// However, it will usually result in less memory allocation
|
|
const readSize = opt.maxReadSize || 16*1024*1024
|
|
const stream = new fsm.ReadStreamSync(file, {
|
|
readSize: readSize,
|
|
size: stat.size
|
|
})
|
|
stream.pipe(u)
|
|
}
|
|
|
|
const extractFile = (opt, cb) => {
|
|
const u = new Unpack(opt)
|
|
const readSize = opt.maxReadSize || 16*1024*1024
|
|
|
|
const file = opt.file
|
|
const p = new Promise((resolve, reject) => {
|
|
u.on('error', reject)
|
|
u.on('close', resolve)
|
|
|
|
// This trades a zero-byte read() syscall for a stat
|
|
// However, it will usually result in less memory allocation
|
|
fs.stat(file, (er, stat) => {
|
|
if (er)
|
|
reject(er)
|
|
else {
|
|
const stream = new fsm.ReadStream(file, {
|
|
readSize: readSize,
|
|
size: stat.size
|
|
})
|
|
stream.on('error', reject)
|
|
stream.pipe(u)
|
|
}
|
|
})
|
|
})
|
|
return cb ? p.then(cb, cb) : p
|
|
}
|
|
|
|
const extractSync = opt => {
|
|
return new Unpack.Sync(opt)
|
|
}
|
|
|
|
const extract = opt => {
|
|
return new Unpack(opt)
|
|
}
|
|
</pre></td></tr>
|
|
</table></pre>
|
|
<div class='push'></div><!-- for sticky footer -->
|
|
</div><!-- /wrapper -->
|
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
Code coverage
|
|
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Mon Nov 20 2017 16:00:38 GMT-0800 (PST)
|
|
</div>
|
|
</div>
|
|
<script src="../../prettify.js"></script>
|
|
<script>
|
|
window.onload = function () {
|
|
if (typeof prettyPrint === 'function') {
|
|
prettyPrint();
|
|
}
|
|
};
|
|
</script>
|
|
<script src="../../sorter.js"></script>
|
|
</body>
|
|
</html>
|
|
|