diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-06-19 09:51:28 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-06-19 09:51:28 +0300 |
commit | df894930f2716adac28740b29b2e863170919990 (patch) | |
tree | 19d8ed438b9f259ac3d0a51d512a776e666004e1 /node_modules/fstream | |
parent | 974404934758124aa8ae5b54f7d5257c3bd6b588 (diff) |
fstream@1.0.7
Standardized and with new tap.
Contributed by @isaacs, unsurprisingly.
PR-URL: https://github.com/npm/fstream/pull/44
Diffstat (limited to 'node_modules/fstream')
-rw-r--r-- | node_modules/fstream/examples/filter-pipe.js | 19 | ||||
-rw-r--r-- | node_modules/fstream/examples/pipe.js | 17 | ||||
-rw-r--r-- | node_modules/fstream/examples/symlink-write.js | 2 | ||||
-rw-r--r-- | node_modules/fstream/lib/abstract.js | 32 | ||||
-rw-r--r-- | node_modules/fstream/lib/dir-writer.js | 4 | ||||
-rw-r--r-- | node_modules/fstream/lib/file-reader.js | 10 | ||||
-rw-r--r-- | node_modules/fstream/lib/link-reader.js | 2 | ||||
-rw-r--r-- | node_modules/fstream/lib/link-writer.js | 6 | ||||
-rw-r--r-- | node_modules/fstream/lib/reader.js | 24 | ||||
-rw-r--r-- | node_modules/fstream/lib/writer.js | 18 | ||||
-rw-r--r-- | node_modules/fstream/package.json | 42 |
11 files changed, 78 insertions, 98 deletions
diff --git a/node_modules/fstream/examples/filter-pipe.js b/node_modules/fstream/examples/filter-pipe.js index fc59cfc7a..83dadef8a 100644 --- a/node_modules/fstream/examples/filter-pipe.js +++ b/node_modules/fstream/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/node_modules/fstream/examples/pipe.js b/node_modules/fstream/examples/pipe.js index c611dd5c4..3de42ef32 100644 --- a/node_modules/fstream/examples/pipe.js +++ b/node_modules/fstream/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/node_modules/fstream/examples/symlink-write.js b/node_modules/fstream/examples/symlink-write.js index f6f51099b..19e81eea9 100644 --- a/node_modules/fstream/examples/symlink-write.js +++ b/node_modules/fstream/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/node_modules/fstream/lib/abstract.js b/node_modules/fstream/lib/abstract.js index 94af1ae08..97c120e1d 100644 --- a/node_modules/fstream/lib/abstract.js +++ b/node_modules/fstream/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/node_modules/fstream/lib/dir-writer.js b/node_modules/fstream/lib/dir-writer.js index aed9e4db1..ec50dca90 100644 --- a/node_modules/fstream/lib/dir-writer.js +++ b/node_modules/fstream/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/node_modules/fstream/lib/file-reader.js b/node_modules/fstream/lib/file-reader.js index 0757b286b..baa01f4b3 100644 --- a/node_modules/fstream/lib/file-reader.js +++ b/node_modules/fstream/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/node_modules/fstream/lib/link-reader.js b/node_modules/fstream/lib/link-reader.js index a44dd39d7..fb4cc67a9 100644 --- a/node_modules/fstream/lib/link-reader.js +++ b/node_modules/fstream/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/node_modules/fstream/lib/link-writer.js b/node_modules/fstream/lib/link-writer.js index 07a9abf7e..af5428400 100644 --- a/node_modules/fstream/lib/link-writer.js +++ b/node_modules/fstream/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/node_modules/fstream/lib/reader.js b/node_modules/fstream/lib/reader.js index 1d007ee21..876021f92 100644 --- a/node_modules/fstream/lib/reader.js +++ b/node_modules/fstream/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/node_modules/fstream/lib/writer.js b/node_modules/fstream/lib/writer.js index 25a608def..ca3396b5d 100644 --- a/node_modules/fstream/lib/writer.js +++ b/node_modules/fstream/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/node_modules/fstream/package.json b/node_modules/fstream/package.json index aa6bc1cf3..0109d940c 100644 --- a/node_modules/fstream/package.json +++ b/node_modules/fstream/package.json @@ -6,7 +6,7 @@ }, "name": "fstream", "description": "Advanced file system stream things", - "version": "1.0.6", + "version": "1.0.7", "repository": { "type": "git", "url": "git://github.com/isaacs/fstream.git" @@ -22,45 +22,21 @@ "rimraf": "2" }, "devDependencies": { - "tap": "0", - "standard": "^2.3.2" + "standard": "^4.0.0", + "tap": "^1.2.0" }, "scripts": { "test": "standard && tap examples/*.js" }, "license": "ISC", - "gitHead": "e0c0024379c5a94ca228d232e2794b6ffb0d3caf", + "readme": "Like FS streams, but with stat on them, and supporting directories and\nsymbolic links, as well as normal files. Also, you can use this to set\nthe stats on a file, even if you don't change its contents, or to create\na symlink, etc.\n\nSo, for example, you can \"write\" a directory, and it'll call `mkdir`. You\ncan specify a uid and gid, and it'll call `chown`. You can specify a\n`mtime` and `atime`, and it'll call `utimes`. You can call it a symlink\nand provide a `linkpath` and it'll call `symlink`.\n\nNote that it won't automatically resolve symbolic links. So, if you\ncall `fstream.Reader('/some/symlink')` then you'll get an object\nthat stats and then ends immediately (since it has no data). To follow\nsymbolic links, do this: `fstream.Reader({path:'/some/symlink', follow:\ntrue })`.\n\nThere are various checks to make sure that the bytes emitted are the\nsame as the intended size, if the size is set.\n\n## Examples\n\n```javascript\nfstream\n .Writer({ path: \"path/to/file\"\n , mode: 0755\n , size: 6\n })\n .write(\"hello\\n\")\n .end()\n```\n\nThis will create the directories if they're missing, and then write\n`hello\\n` into the file, chmod it to 0755, and assert that 6 bytes have\nbeen written when it's done.\n\n```javascript\nfstream\n .Writer({ path: \"path/to/file\"\n , mode: 0755\n , size: 6\n , flags: \"a\"\n })\n .write(\"hello\\n\")\n .end()\n```\n\nYou can pass flags in, if you want to append to a file.\n\n```javascript\nfstream\n .Writer({ path: \"path/to/symlink\"\n , linkpath: \"./file\"\n , SymbolicLink: true\n , mode: \"0755\" // octal strings supported\n })\n .end()\n```\n\nIf isSymbolicLink is a function, it'll be called, and if it returns\ntrue, then it'll treat it as a symlink. If it's not a function, then\nany truish value will make a symlink, or you can set `type:\n'SymbolicLink'`, which does the same thing.\n\nNote that the linkpath is relative to the symbolic link location, not\nthe parent dir or cwd.\n\n```javascript\nfstream\n .Reader(\"path/to/dir\")\n .pipe(fstream.Writer(\"path/to/other/dir\"))\n```\n\nThis will do like `cp -Rp path/to/dir path/to/other/dir`. If the other\ndir exists and isn't a directory, then it'll emit an error. It'll also\nset the uid, gid, mode, etc. to be identical. In this way, it's more\nlike `rsync -a` than simply a copy.\n", + "readmeFilename": "README.md", + "gitHead": "586e8efc1cf77883f6c22fc32a7cb38f0eb88911", "bugs": { "url": "https://github.com/isaacs/fstream/issues" }, "homepage": "https://github.com/isaacs/fstream#readme", - "_id": "fstream@1.0.6", - "_shasum": "817e50312fb4ed90da865c8eb5ecd1d1d7aed0ec", - "_from": "fstream@>=1.0.6 <1.1.0", - "_npmVersion": "2.9.0", - "_nodeVersion": "2.0.0", - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "dist": { - "shasum": "817e50312fb4ed90da865c8eb5ecd1d1d7aed0ec", - "tarball": "http://registry.npmjs.org/fstream/-/fstream-1.0.6.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.6.tgz" + "_id": "fstream@1.0.7", + "_shasum": "455a1aa1d46077668d95b6d27838e1b1daa78c78", + "_from": "fstream@>=1.0.7 <1.1.0" } |