From 3a1a88b6b2a65d2bb70b8d121a80e5be48549818 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sun, 31 May 2015 21:59:30 -0700 Subject: [PATCH] standard@4.0.0 and tap@1.2.0 --- examples/filter-pipe.js | 19 ++++++++++--------- examples/pipe.js | 17 +++++++++-------- examples/symlink-write.js | 2 ++ lib/abstract.js | 32 ++++++++++++++++---------------- lib/dir-writer.js | 4 ++-- lib/file-reader.js | 10 +++++----- lib/link-reader.js | 2 +- lib/link-writer.js | 6 +++--- lib/reader.js | 24 ++++++++++++------------ lib/writer.js | 18 +++++++++--------- package.json | 4 ++-- 11 files changed, 71 insertions(+), 67 deletions(-) diff --git a/examples/filter-pipe.js b/examples/filter-pipe.js index fc59cfc..83dadef 100644 --- a/examples/filter-pipe.js +++ b/examples/filter-pipe.js @@ -81,9 +81,9 @@ function missile (entry) { return function (c) { var e = Math.random() < 0.5 console.error(indent + '%s %s for %d damage!', - entry.basename, - e ? 'is struck' : 'fires a chunk', - c.length) + entry.basename, + e ? 'is struck' : 'fires a chunk', + c.length) } } @@ -91,8 +91,8 @@ function runaway (entry) { return function () { var e = Math.random() < 0.5 console.error(indent + '%s %s', - entry.basename, - e ? 'turns to flee' : 'is vanquished!') + entry.basename, + e ? 'turns to flee' : 'is vanquished!') indent = indent.slice(0, -1) } } @@ -101,7 +101,7 @@ w.on('entry', attacks) // w.on('ready', function () { attacks(w) }) function attacks (entry) { console.error(indent + '%s %s!', entry.basename, - entry.type === 'Directory' ? 'calls for backup' : 'attacks') + entry.type === 'Directory' ? 'calls for backup' : 'attacks') entry.on('entry', attacks) } @@ -121,13 +121,14 @@ r.on('end', function () { checker.on('child', function (e) { var ok = e.type === 'Directory' console.log((ok ? '' : 'not ') + 'ok ' + (i++) + - ' should be a dir: ' + - e.path.substr(checker.path.length + 1)) + ' should be a dir: ' + + e.path.substr(checker.path.length + 1)) }) }) process.on('exit', function () { - console.log((ended ? '' : 'not ') + 'ok ' + (i++) + ' ended') + console.log((ended ? '' : 'not ') + 'ok ' + (i) + ' ended') + console.log('1..' + i) }) r.pipe(w) diff --git a/examples/pipe.js b/examples/pipe.js index c611dd5..3de42ef 100644 --- a/examples/pipe.js +++ b/examples/pipe.js @@ -5,8 +5,8 @@ var r = fstream.Reader({ path: path.dirname(__dirname), filter: function () { return !this.basename.match(/^\./) && - !this.basename.match(/^node_modules$/) && - !this.basename.match(/^deep-copy$/) + !this.basename.match(/^node_modules$/) && + !this.basename.match(/^deep-copy$/) } }) @@ -76,9 +76,9 @@ function missile (entry) { return function (c) { var e = Math.random() < 0.5 console.error(indent + '%s %s for %d damage!', - entry.basename, - e ? 'is struck' : 'fires a chunk', - c.length) + entry.basename, + e ? 'is struck' : 'fires a chunk', + c.length) } } @@ -86,8 +86,8 @@ function runaway (entry) { return function () { var e = Math.random() < 0.5 console.error(indent + '%s %s', - entry.basename, - e ? 'turns to flee' : 'is vanquished!') + entry.basename, + e ? 'turns to flee' : 'is vanquished!') indent = indent.slice(0, -1) } } @@ -96,7 +96,7 @@ w.on('entry', attacks) // w.on('ready', function () { attacks(w) }) function attacks (entry) { console.error(indent + '%s %s!', entry.basename, - entry.type === 'Directory' ? 'calls for backup' : 'attacks') + entry.type === 'Directory' ? 'calls for backup' : 'attacks') entry.on('entry', attacks) } @@ -112,6 +112,7 @@ r.on('end', function () { process.on('exit', function () { console.log((ended ? '' : 'not ') + 'ok 2 ended') + console.log('1..2') }) r.pipe(w) diff --git a/examples/symlink-write.js b/examples/symlink-write.js index f6f5109..19e81ee 100644 --- a/examples/symlink-write.js +++ b/examples/symlink-write.js @@ -1,5 +1,6 @@ var fstream = require('../fstream.js') var notOpen = false +process.chdir(__dirname) fstream .Writer({ @@ -22,4 +23,5 @@ fstream process.on('exit', function () { console.log((notOpen ? '' : 'not ') + 'ok 3 should be closed') + console.log('1..3') }) diff --git a/lib/abstract.js b/lib/abstract.js index 94af1ae..97c120e 100644 --- a/lib/abstract.js +++ b/lib/abstract.js @@ -32,22 +32,22 @@ Abstract.prototype.warn = function (msg, code) { var er = decorate(msg, code, self) if (!self.listeners('warn')) { console.error('%s %s\n' + - 'path = %s\n' + - 'syscall = %s\n' + - 'fstream_type = %s\n' + - 'fstream_path = %s\n' + - 'fstream_unc_path = %s\n' + - 'fstream_class = %s\n' + - 'fstream_stack =\n%s\n', - code || 'UNKNOWN', - er.stack, - er.path, - er.syscall, - er.fstream_type, - er.fstream_path, - er.fstream_unc_path, - er.fstream_class, - er.fstream_stack.join('\n')) + 'path = %s\n' + + 'syscall = %s\n' + + 'fstream_type = %s\n' + + 'fstream_path = %s\n' + + 'fstream_unc_path = %s\n' + + 'fstream_class = %s\n' + + 'fstream_stack =\n%s\n', + code || 'UNKNOWN', + er.stack, + er.path, + er.syscall, + er.fstream_type, + er.fstream_path, + er.fstream_unc_path, + er.fstream_class, + er.fstream_stack.join('\n')) } else { self.emit('warn', er) } diff --git a/lib/dir-writer.js b/lib/dir-writer.js index aed9e4d..ec50dca 100644 --- a/lib/dir-writer.js +++ b/lib/dir-writer.js @@ -23,7 +23,7 @@ function DirWriter (props) { // should already be established as a Directory type if (props.type !== 'Directory' || !props.Directory) { self.error('Non-directory type ' + props.type + ' ' + - JSON.stringify(props), null, true) + JSON.stringify(props), null, true) } Writer.call(this, props) @@ -102,7 +102,7 @@ DirWriter.prototype._process = function () { do { pp = p._path || p.path if (pp === self.root._path || pp === self._path || - (pp && pp.indexOf(self._path) === 0)) { + (pp && pp.indexOf(self._path) === 0)) { // console.error('DW Exit (recursive)', entry.basename, self._path) self._processing = false if (entry._collected) entry.pipe() diff --git a/lib/file-reader.js b/lib/file-reader.js index 0757b28..baa01f4 100644 --- a/lib/file-reader.js +++ b/lib/file-reader.js @@ -21,7 +21,7 @@ function FileReader (props) { // XXX Todo: preserve hardlinks by tracking dev+inode+nlink, // with a HardLinkReader class. if (!((props.type === 'Link' && props.Link) || - (props.type === 'File' && props.File))) { + (props.type === 'File' && props.File))) { throw new Error('Non-file type ' + props.type) } @@ -63,8 +63,8 @@ FileReader.prototype._getStream = function () { if (self._bytesEmitted !== self.props.size) { self.error("Didn't get expected byte count\n" + - 'expect: ' + self.props.size + '\n' + - 'actual: ' + self._bytesEmitted) + 'expect: ' + self.props.size + '\n' + + 'actual: ' + self._bytesEmitted) } }) @@ -124,8 +124,8 @@ FileReader.prototype._read = function () { } self._buffer.length = 0 } - // console.error("FR _read done") - // that's about all there is to it. +// console.error("FR _read done") +// that's about all there is to it. } FileReader.prototype.pause = function (who) { diff --git a/lib/link-reader.js b/lib/link-reader.js index a44dd39..fb4cc67 100644 --- a/lib/link-reader.js +++ b/lib/link-reader.js @@ -19,7 +19,7 @@ function LinkReader (props) { } if (!((props.type === 'Link' && props.Link) || - (props.type === 'SymbolicLink' && props.SymbolicLink))) { + (props.type === 'SymbolicLink' && props.SymbolicLink))) { throw new Error('Non-link type ' + props.type) } diff --git a/lib/link-writer.js b/lib/link-writer.js index 07a9abf..af54284 100644 --- a/lib/link-writer.js +++ b/lib/link-writer.js @@ -16,7 +16,7 @@ function LinkWriter (props) { // should already be established as a Link type if (!((props.type === 'Link' && props.Link) || - (props.type === 'SymbolicLink' && props.SymbolicLink))) { + (props.type === 'SymbolicLink' && props.SymbolicLink))) { throw new Error('Non-link type ' + props.type) } @@ -66,8 +66,8 @@ function create (self, lp, link) { // windows in some nice fashion. if (er) { if ((er.code === 'ENOENT' || - er.code === 'EACCES' || - er.code === 'EPERM') && process.platform === 'win32') { + er.code === 'EACCES' || + er.code === 'EPERM') && process.platform === 'win32') { self.ready = true self.emit('ready') self.emit('end') diff --git a/lib/reader.js b/lib/reader.js index 1d007ee..876021f 100644 --- a/lib/reader.js +++ b/lib/reader.js @@ -54,13 +54,13 @@ function Reader (props, currentStat) { break case 'Link': - // XXX hard links are just files. - // However, it would be good to keep track of files' dev+inode - // and nlink values, and create a HardLinkReader that emits - // a linkpath value of the original copy, so that the tar - // writer can preserve them. - // ClassType = HardLinkReader - // break + // XXX hard links are just files. + // However, it would be good to keep track of files' dev+inode + // and nlink values, and create a HardLinkReader that emits + // a linkpath value of the original copy, so that the tar + // writer can preserve them. + // ClassType = HardLinkReader + // break case 'File': ClassType = require('./file-reader.js') @@ -103,7 +103,7 @@ function Reader (props, currentStat) { self._swallowErrors = true // if (self._path.indexOf(" ") === -1) { self._path = '\\\\?\\' + self.path.replace(/\//g, '\\') - // } + // } } } self.basename = props.basename = path.basename(self.path) @@ -126,10 +126,10 @@ function Reader (props, currentStat) { function alphasort (a, b) { return a === b ? 0 - : a.toLowerCase() > b.toLowerCase() ? 1 - : a.toLowerCase() < b.toLowerCase() ? -1 - : a > b ? 1 - : -1 + : a.toLowerCase() > b.toLowerCase() ? 1 + : a.toLowerCase() < b.toLowerCase() ? -1 + : a > b ? 1 + : -1 } Reader.prototype._stat = function (currentStat) { diff --git a/lib/writer.js b/lib/writer.js index 25a608d..ca3396b 100644 --- a/lib/writer.js +++ b/lib/writer.js @@ -113,7 +113,7 @@ Writer.prototype._create = function () { fs[self.props.follow ? 'stat' : 'lstat'](self._path, function (er) { if (er) { return self.warn('Cannot create ' + self._path + '\n' + - 'Unsupported type: ' + self.type, 'ENOTSUP') + 'Unsupported type: ' + self.type, 'ENOTSUP') } self._finish() }) @@ -179,7 +179,7 @@ function create (self) { function endChmod (self, want, current, path, cb) { var wantMode = want.mode var chmod = want.follow || self.type !== 'SymbolicLink' - ? 'chmod' : 'lchmod' + ? 'chmod' : 'lchmod' if (!fs[chmod]) return cb() if (typeof wantMode !== 'number') return cb() @@ -196,13 +196,13 @@ function endChown (self, want, current, path, cb) { if (process.platform === 'win32') return cb() if (!process.getuid || process.getuid() !== 0) return cb() if (typeof want.uid !== 'number' && - typeof want.gid !== 'number') return cb() + typeof want.gid !== 'number') return cb() if (current.uid === want.uid && - current.gid === want.gid) return cb() + current.gid === want.gid) return cb() var chown = (self.props.follow || self.type !== 'SymbolicLink') - ? 'chown' : 'lchown' + ? 'chown' : 'lchown' if (!fs[chown]) return cb() if (typeof want.uid !== 'number') want.uid = current.uid @@ -215,7 +215,7 @@ function endUtimes (self, want, current, path, cb) { if (!fs.utimes || process.platform === 'win32') return cb() var utimes = (want.follow || self.type !== 'SymbolicLink') - ? 'utimes' : 'lutimes' + ? 'utimes' : 'lutimes' if (utimes === 'lutimes' && !fs[utimes]) { utimes = 'utimes' @@ -235,7 +235,7 @@ function endUtimes (self, want, current, path, cb) { if (!isDate(meM)) meA = new Date(meM) if (meA.getTime() === curA.getTime() && - meM.getTime() === curM.getTime()) return cb() + meM.getTime() === curM.getTime()) return cb() fs[utimes](path, meA, meM, cb) } @@ -274,8 +274,8 @@ Writer.prototype._finish = function () { // doesn't exist yet (especially if it was intended as a symlink), // so swallow ENOENT errors here and just soldier on. if (er.code === 'ENOENT' && - (self.type === 'Link' || self.type === 'SymbolicLink') && - process.platform === 'win32') { + (self.type === 'Link' || self.type === 'SymbolicLink') && + process.platform === 'win32') { self.ready = true self.emit('ready') self.emit('end') diff --git a/package.json b/package.json index 294706e..8325b15 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "rimraf": "2" }, "devDependencies": { - "tap": "0", - "standard": "^2.3.2" + "standard": "^4.0.0", + "tap": "^1.2.0" }, "scripts": { "test": "standard && tap examples/*.js"