create-torrent
Advanced tools
Comparing version 4.4.5 to 4.5.0
35
index.js
@@ -121,10 +121,12 @@ /*! create-torrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */ | ||
// remove junk files | ||
input = input.filter(item => { | ||
if (typeof item === 'string') { | ||
return true | ||
} | ||
const filename = item.path[item.path.length - 1] | ||
return notHidden(filename) && junk.not(filename) | ||
}) | ||
const filterJunkFiles = opts.filterJunkFiles === undefined ? true : opts.filterJunkFiles | ||
if (filterJunkFiles) { | ||
// Remove junk files | ||
input = input.filter(item => { | ||
if (typeof item === 'string') { | ||
return true | ||
} | ||
return !isJunkPath(item.path) | ||
}) | ||
} | ||
@@ -213,6 +215,2 @@ if (commonPrefix) { | ||
function notHidden (file) { | ||
return file[0] !== '.' | ||
} | ||
function getPieceList (files, pieceLength, cb) { | ||
@@ -356,2 +354,14 @@ cb = once(cb) | ||
/** | ||
* Determine if a a file is junk based on its path | ||
* (defined as hidden OR recognized by the `junk` package) | ||
* | ||
* @param {string} path | ||
* @return {boolean} | ||
*/ | ||
function isJunkPath (path) { | ||
const filename = path[path.length - 1] | ||
return filename[0] === '.' && junk.is(filename) | ||
} | ||
/** | ||
* Accumulator to sum file lengths | ||
@@ -439,1 +449,2 @@ * @param {number} sum | ||
module.exports.announceList = announceList | ||
module.exports.isJunkPath = isJunkPath |
{ | ||
"name": "create-torrent", | ||
"description": "Create .torrent files", | ||
"version": "4.4.5", | ||
"version": "4.5.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "WebTorrent LLC", |
@@ -68,2 +68,3 @@ # create-torrent [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] | ||
creationDate: Date // creation time in UNIX epoch format (default = now) | ||
filterJunkFiles: Boolean, // remove hidden and other junk files? (default = true) | ||
private: Boolean, // is this a private .torrent? (default = false) | ||
@@ -70,0 +71,0 @@ pieceLength: Number, // force a custom piece length (number of bytes) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23608
517
127