Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 3a1a88b

Browse files
committed
1 parent e0c0024 commit 3a1a88b

File tree

11 files changed

+71
-67
lines changed

11 files changed

+71
-67
lines changed

examples/filter-pipe.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ function missile (entry) {
8181
return function (c) {
8282
var e = Math.random() < 0.5
8383
console.error(indent + '%s %s for %d damage!',
84-
entry.basename,
85-
e ? 'is struck' : 'fires a chunk',
86-
c.length)
84+
entry.basename,
85+
e ? 'is struck' : 'fires a chunk',
86+
c.length)
8787
}
8888
}
8989

9090
function runaway (entry) {
9191
return function () {
9292
var e = Math.random() < 0.5
9393
console.error(indent + '%s %s',
94-
entry.basename,
95-
e ? 'turns to flee' : 'is vanquished!')
94+
entry.basename,
95+
e ? 'turns to flee' : 'is vanquished!')
9696
indent = indent.slice(0, -1)
9797
}
9898
}
@@ -101,7 +101,7 @@ w.on('entry', attacks)
101101
// w.on('ready', function () { attacks(w) })
102102
function attacks (entry) {
103103
console.error(indent + '%s %s!', entry.basename,
104-
entry.type === 'Directory' ? 'calls for backup' : 'attacks')
104+
entry.type === 'Directory' ? 'calls for backup' : 'attacks')
105105
entry.on('entry', attacks)
106106
}
107107

@@ -121,13 +121,14 @@ r.on('end', function () {
121121
checker.on('child', function (e) {
122122
var ok = e.type === 'Directory'
123123
console.log((ok ? '' : 'not ') + 'ok ' + (i++) +
124-
' should be a dir: ' +
125-
e.path.substr(checker.path.length + 1))
124+
' should be a dir: ' +
125+
e.path.substr(checker.path.length + 1))
126126
})
127127
})
128128

129129
process.on('exit', function () {
130-
console.log((ended ? '' : 'not ') + 'ok ' + (i++) + ' ended')
130+
console.log((ended ? '' : 'not ') + 'ok ' + (i) + ' ended')
131+
console.log('1..' + i)
131132
})
132133

133134
r.pipe(w)

examples/pipe.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ var r = fstream.Reader({
55
path: path.dirname(__dirname),
66
filter: function () {
77
return !this.basename.match(/^\./) &&
8-
!this.basename.match(/^node_modules$/) &&
9-
!this.basename.match(/^deep-copy$/)
8+
!this.basename.match(/^node_modules$/) &&
9+
!this.basename.match(/^deep-copy$/)
1010
}
1111
})
1212

@@ -76,18 +76,18 @@ function missile (entry) {
7676
return function (c) {
7777
var e = Math.random() < 0.5
7878
console.error(indent + '%s %s for %d damage!',
79-
entry.basename,
80-
e ? 'is struck' : 'fires a chunk',
81-
c.length)
79+
entry.basename,
80+
e ? 'is struck' : 'fires a chunk',
81+
c.length)
8282
}
8383
}
8484

8585
function runaway (entry) {
8686
return function () {
8787
var e = Math.random() < 0.5
8888
console.error(indent + '%s %s',
89-
entry.basename,
90-
e ? 'turns to flee' : 'is vanquished!')
89+
entry.basename,
90+
e ? 'turns to flee' : 'is vanquished!')
9191
indent = indent.slice(0, -1)
9292
}
9393
}
@@ -96,7 +96,7 @@ w.on('entry', attacks)
9696
// w.on('ready', function () { attacks(w) })
9797
function attacks (entry) {
9898
console.error(indent + '%s %s!', entry.basename,
99-
entry.type === 'Directory' ? 'calls for backup' : 'attacks')
99+
entry.type === 'Directory' ? 'calls for backup' : 'attacks')
100100
entry.on('entry', attacks)
101101
}
102102

@@ -112,6 +112,7 @@ r.on('end', function () {
112112

113113
process.on('exit', function () {
114114
console.log((ended ? '' : 'not ') + 'ok 2 ended')
115+
console.log('1..2')
115116
})
116117

117118
r.pipe(w)

examples/symlink-write.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var fstream = require('../fstream.js')
22
var notOpen = false
3+
process.chdir(__dirname)
34

45
fstream
56
.Writer({
@@ -22,4 +23,5 @@ fstream
2223

2324
process.on('exit', function () {
2425
console.log((notOpen ? '' : 'not ') + 'ok 3 should be closed')
26+
console.log('1..3')
2527
})

lib/abstract.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ Abstract.prototype.warn = function (msg, code) {
3232
var er = decorate(msg, code, self)
3333
if (!self.listeners('warn')) {
3434
console.error('%s %s\n' +
35-
'path = %s\n' +
36-
'syscall = %s\n' +
37-
'fstream_type = %s\n' +
38-
'fstream_path = %s\n' +
39-
'fstream_unc_path = %s\n' +
40-
'fstream_class = %s\n' +
41-
'fstream_stack =\n%s\n',
42-
code || 'UNKNOWN',
43-
er.stack,
44-
er.path,
45-
er.syscall,
46-
er.fstream_type,
47-
er.fstream_path,
48-
er.fstream_unc_path,
49-
er.fstream_class,
50-
er.fstream_stack.join('\n'))
35+
'path = %s\n' +
36+
'syscall = %s\n' +
37+
'fstream_type = %s\n' +
38+
'fstream_path = %s\n' +
39+
'fstream_unc_path = %s\n' +
40+
'fstream_class = %s\n' +
41+
'fstream_stack =\n%s\n',
42+
code || 'UNKNOWN',
43+
er.stack,
44+
er.path,
45+
er.syscall,
46+
er.fstream_type,
47+
er.fstream_path,
48+
er.fstream_unc_path,
49+
er.fstream_class,
50+
er.fstream_stack.join('\n'))
5151
} else {
5252
self.emit('warn', er)
5353
}

lib/dir-writer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function DirWriter (props) {
2323
// should already be established as a Directory type
2424
if (props.type !== 'Directory' || !props.Directory) {
2525
self.error('Non-directory type ' + props.type + ' ' +
26-
JSON.stringify(props), null, true)
26+
JSON.stringify(props), null, true)
2727
}
2828

2929
Writer.call(this, props)
@@ -102,7 +102,7 @@ DirWriter.prototype._process = function () {
102102
do {
103103
pp = p._path || p.path
104104
if (pp === self.root._path || pp === self._path ||
105-
(pp && pp.indexOf(self._path) === 0)) {
105+
(pp && pp.indexOf(self._path) === 0)) {
106106
// console.error('DW Exit (recursive)', entry.basename, self._path)
107107
self._processing = false
108108
if (entry._collected) entry.pipe()

lib/file-reader.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function FileReader (props) {
2121
// XXX Todo: preserve hardlinks by tracking dev+inode+nlink,
2222
// with a HardLinkReader class.
2323
if (!((props.type === 'Link' && props.Link) ||
24-
(props.type === 'File' && props.File))) {
24+
(props.type === 'File' && props.File))) {
2525
throw new Error('Non-file type ' + props.type)
2626
}
2727

@@ -63,8 +63,8 @@ FileReader.prototype._getStream = function () {
6363

6464
if (self._bytesEmitted !== self.props.size) {
6565
self.error("Didn't get expected byte count\n" +
66-
'expect: ' + self.props.size + '\n' +
67-
'actual: ' + self._bytesEmitted)
66+
'expect: ' + self.props.size + '\n' +
67+
'actual: ' + self._bytesEmitted)
6868
}
6969
})
7070

@@ -124,8 +124,8 @@ FileReader.prototype._read = function () {
124124
}
125125
self._buffer.length = 0
126126
}
127-
// console.error("FR _read done")
128-
// that's about all there is to it.
127+
// console.error("FR _read done")
128+
// that's about all there is to it.
129129
}
130130

131131
FileReader.prototype.pause = function (who) {

lib/link-reader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function LinkReader (props) {
1919
}
2020

2121
if (!((props.type === 'Link' && props.Link) ||
22-
(props.type === 'SymbolicLink' && props.SymbolicLink))) {
22+
(props.type === 'SymbolicLink' && props.SymbolicLink))) {
2323
throw new Error('Non-link type ' + props.type)
2424
}
2525

lib/link-writer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function LinkWriter (props) {
1616

1717
// should already be established as a Link type
1818
if (!((props.type === 'Link' && props.Link) ||
19-
(props.type === 'SymbolicLink' && props.SymbolicLink))) {
19+
(props.type === 'SymbolicLink' && props.SymbolicLink))) {
2020
throw new Error('Non-link type ' + props.type)
2121
}
2222

@@ -66,8 +66,8 @@ function create (self, lp, link) {
6666
// windows in some nice fashion.
6767
if (er) {
6868
if ((er.code === 'ENOENT' ||
69-
er.code === 'EACCES' ||
70-
er.code === 'EPERM') && process.platform === 'win32') {
69+
er.code === 'EACCES' ||
70+
er.code === 'EPERM') && process.platform === 'win32') {
7171
self.ready = true
7272
self.emit('ready')
7373
self.emit('end')

lib/reader.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ function Reader (props, currentStat) {
5454
break
5555

5656
case 'Link':
57-
// XXX hard links are just files.
58-
// However, it would be good to keep track of files' dev+inode
59-
// and nlink values, and create a HardLinkReader that emits
60-
// a linkpath value of the original copy, so that the tar
61-
// writer can preserve them.
62-
// ClassType = HardLinkReader
63-
// break
57+
// XXX hard links are just files.
58+
// However, it would be good to keep track of files' dev+inode
59+
// and nlink values, and create a HardLinkReader that emits
60+
// a linkpath value of the original copy, so that the tar
61+
// writer can preserve them.
62+
// ClassType = HardLinkReader
63+
// break
6464

6565
case 'File':
6666
ClassType = require('./file-reader.js')
@@ -103,7 +103,7 @@ function Reader (props, currentStat) {
103103
self._swallowErrors = true
104104
// if (self._path.indexOf(" ") === -1) {
105105
self._path = '\\\\?\\' + self.path.replace(/\//g, '\\')
106-
// }
106+
// }
107107
}
108108
}
109109
self.basename = props.basename = path.basename(self.path)
@@ -126,10 +126,10 @@ function Reader (props, currentStat) {
126126

127127
function alphasort (a, b) {
128128
return a === b ? 0
129-
: a.toLowerCase() > b.toLowerCase() ? 1
130-
: a.toLowerCase() < b.toLowerCase() ? -1
131-
: a > b ? 1
132-
: -1
129+
: a.toLowerCase() > b.toLowerCase() ? 1
130+
: a.toLowerCase() < b.toLowerCase() ? -1
131+
: a > b ? 1
132+
: -1
133133
}
134134

135135
Reader.prototype._stat = function (currentStat) {

lib/writer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Writer.prototype._create = function () {
113113
fs[self.props.follow ? 'stat' : 'lstat'](self._path, function (er) {
114114
if (er) {
115115
return self.warn('Cannot create ' + self._path + '\n' +
116-
'Unsupported type: ' + self.type, 'ENOTSUP')
116+
'Unsupported type: ' + self.type, 'ENOTSUP')
117117
}
118118
self._finish()
119119
})
@@ -179,7 +179,7 @@ function create (self) {
179179
function endChmod (self, want, current, path, cb) {
180180
var wantMode = want.mode
181181
var chmod = want.follow || self.type !== 'SymbolicLink'
182-
? 'chmod' : 'lchmod'
182+
? 'chmod' : 'lchmod'
183183

184184
if (!fs[chmod]) return cb()
185185
if (typeof wantMode !== 'number') return cb()
@@ -196,13 +196,13 @@ function endChown (self, want, current, path, cb) {
196196
if (process.platform === 'win32') return cb()
197197
if (!process.getuid || process.getuid() !== 0) return cb()
198198
if (typeof want.uid !== 'number' &&
199-
typeof want.gid !== 'number') return cb()
199+
typeof want.gid !== 'number') return cb()
200200

201201
if (current.uid === want.uid &&
202-
current.gid === want.gid) return cb()
202+
current.gid === want.gid) return cb()
203203

204204
var chown = (self.props.follow || self.type !== 'SymbolicLink')
205-
? 'chown' : 'lchown'
205+
? 'chown' : 'lchown'
206206
if (!fs[chown]) return cb()
207207

208208
if (typeof want.uid !== 'number') want.uid = current.uid
@@ -215,7 +215,7 @@ function endUtimes (self, want, current, path, cb) {
215215
if (!fs.utimes || process.platform === 'win32') return cb()
216216

217217
var utimes = (want.follow || self.type !== 'SymbolicLink')
218-
? 'utimes' : 'lutimes'
218+
? 'utimes' : 'lutimes'
219219

220220
if (utimes === 'lutimes' && !fs[utimes]) {
221221
utimes = 'utimes'
@@ -235,7 +235,7 @@ function endUtimes (self, want, current, path, cb) {
235235
if (!isDate(meM)) meA = new Date(meM)
236236

237237
if (meA.getTime() === curA.getTime() &&
238-
meM.getTime() === curM.getTime()) return cb()
238+
meM.getTime() === curM.getTime()) return cb()
239239

240240
fs[utimes](path, meA, meM, cb)
241241
}
@@ -274,8 +274,8 @@ Writer.prototype._finish = function () {
274274
// doesn't exist yet (especially if it was intended as a symlink),
275275
// so swallow ENOENT errors here and just soldier on.
276276
if (er.code === 'ENOENT' &&
277-
(self.type === 'Link' || self.type === 'SymbolicLink') &&
278-
process.platform === 'win32') {
277+
(self.type === 'Link' || self.type === 'SymbolicLink') &&
278+
process.platform === 'win32') {
279279
self.ready = true
280280
self.emit('ready')
281281
self.emit('end')

0 commit comments

Comments
 (0)