mirror of
https://github.com/S2-/gitlit
synced 2025-08-03 21:00:04 +02:00
add node modules to repo
This commit is contained in:
16
node_modules/klaw/src/assign.js
generated
vendored
Normal file
16
node_modules/klaw/src/assign.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// simple mutable assign (extracted from fs-extra)
|
||||
// I really like object-assign package, but I wanted a lean package with zero deps
|
||||
function _assign () {
|
||||
var args = [].slice.call(arguments).filter(function (i) { return i })
|
||||
var dest = args.shift()
|
||||
args.forEach(function (src) {
|
||||
Object.keys(src).forEach(function (key) {
|
||||
dest[key] = src[key]
|
||||
})
|
||||
})
|
||||
|
||||
return dest
|
||||
}
|
||||
|
||||
// thank you baby Jesus for Node v4 and Object.assign
|
||||
module.exports = Object.assign || _assign
|
57
node_modules/klaw/src/index.js
generated
vendored
Normal file
57
node_modules/klaw/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var assert = require('assert')
|
||||
var fs
|
||||
try {
|
||||
fs = require('graceful-fs')
|
||||
} catch (e) {
|
||||
fs = require('fs')
|
||||
}
|
||||
var path = require('path')
|
||||
var Readable = require('stream').Readable
|
||||
var util = require('util')
|
||||
var assign = require('./assign')
|
||||
|
||||
function Walker (dir, options) {
|
||||
assert.strictEqual(typeof dir, 'string', '`dir` parameter should be of type string. Got type: ' + typeof dir)
|
||||
var defaultStreamOptions = { objectMode: true }
|
||||
var defaultOpts = { queueMethod: 'shift', pathSorter: undefined, filter: undefined }
|
||||
options = assign(defaultOpts, options, defaultStreamOptions)
|
||||
|
||||
Readable.call(this, options)
|
||||
this.root = path.resolve(dir)
|
||||
this.paths = [this.root]
|
||||
this.options = options
|
||||
this.fs = options.fs || fs // mock-fs
|
||||
}
|
||||
util.inherits(Walker, Readable)
|
||||
|
||||
Walker.prototype._read = function () {
|
||||
if (this.paths.length === 0) return this.push(null)
|
||||
var self = this
|
||||
var pathItem = this.paths[this.options.queueMethod]()
|
||||
|
||||
self.fs.lstat(pathItem, function (err, stats) {
|
||||
var item = { path: pathItem, stats: stats }
|
||||
if (err) return self.emit('error', err, item)
|
||||
if (!stats.isDirectory()) return self.push(item)
|
||||
|
||||
self.fs.readdir(pathItem, function (err, pathItems) {
|
||||
if (err) {
|
||||
self.push(item)
|
||||
return self.emit('error', err, item)
|
||||
}
|
||||
|
||||
pathItems = pathItems.map(function (part) { return path.join(pathItem, part) })
|
||||
if (self.options.filter) pathItems = pathItems.filter(self.options.filter)
|
||||
if (self.options.pathSorter) pathItems.sort(self.options.pathSorter)
|
||||
pathItems.forEach(function (pi) { self.paths.push(pi) })
|
||||
|
||||
self.push(item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function walk (root, options) {
|
||||
return new Walker(root, options)
|
||||
}
|
||||
|
||||
module.exports = walk
|
Reference in New Issue
Block a user