Comparing version 6.1.6 to 6.1.7
# Changelog | ||
## 6.1.7 | ||
- Improve documentation and error messaging on ending a stream too early #317 | ||
- bump dependencies | ||
## 6.1.6 | ||
@@ -4,0 +9,0 @@ |
@@ -93,1 +93,7 @@ /*! | ||
} | ||
export declare class EmptyStream extends Error { | ||
constructor(); | ||
} | ||
export declare class EmptySitemap extends Error { | ||
constructor(); | ||
} |
@@ -10,3 +10,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InvalidVideoPriceCurrency = exports.InvalidVideoResolution = exports.InvalidVideoPriceType = exports.InvalidVideoRestrictionRelationship = exports.InvalidVideoRestriction = exports.InvalidVideoFamilyFriendly = exports.InvalidVideoCategory = exports.InvalidVideoTagCount = exports.InvalidVideoViewCount = exports.InvalidVideoTitle = exports.XMLLintUnavailable = exports.InvalidNewsAccessValue = exports.InvalidNewsFormat = exports.InvalidAttr = exports.InvalidAttrValue = exports.InvalidVideoRating = exports.InvalidVideoDescription = exports.InvalidVideoDuration = exports.InvalidVideoFormat = exports.UndefinedTargetFolder = exports.PriorityInvalidError = exports.ChangeFreqInvalidError = exports.NoConfigError = exports.NoURLError = void 0; | ||
exports.EmptySitemap = exports.EmptyStream = exports.InvalidVideoPriceCurrency = exports.InvalidVideoResolution = exports.InvalidVideoPriceType = exports.InvalidVideoRestrictionRelationship = exports.InvalidVideoRestriction = exports.InvalidVideoFamilyFriendly = exports.InvalidVideoCategory = exports.InvalidVideoTagCount = exports.InvalidVideoViewCount = exports.InvalidVideoTitle = exports.XMLLintUnavailable = exports.InvalidNewsAccessValue = exports.InvalidNewsFormat = exports.InvalidAttr = exports.InvalidAttrValue = exports.InvalidVideoRating = exports.InvalidVideoDescription = exports.InvalidVideoDuration = exports.InvalidVideoFormat = exports.UndefinedTargetFolder = exports.PriorityInvalidError = exports.ChangeFreqInvalidError = exports.NoConfigError = exports.NoURLError = void 0; | ||
/** | ||
@@ -231,1 +231,17 @@ * URL in SitemapItem does not exist | ||
exports.InvalidVideoPriceCurrency = InvalidVideoPriceCurrency; | ||
class EmptyStream extends Error { | ||
constructor() { | ||
super('You have ended the stream before anything was written. streamToPromise MUST be called before ending the stream.'); | ||
this.name = 'EmptyStream'; | ||
Error.captureStackTrace(this, EmptyStream); | ||
} | ||
} | ||
exports.EmptyStream = EmptyStream; | ||
class EmptySitemap extends Error { | ||
constructor() { | ||
super('You ended the stream without writing anything.'); | ||
this.name = 'EmptySitemap'; | ||
Error.captureStackTrace(this, EmptyStream); | ||
} | ||
} | ||
exports.EmptySitemap = EmptySitemap; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const sitemap_item_stream_1 = require("./sitemap-item-stream"); | ||
const errors_1 = require("./errors"); | ||
const xmlDec = '<?xml version="1.0" encoding="UTF-8"?>'; | ||
@@ -79,4 +80,9 @@ exports.stylesheetInclude = (url) => { | ||
_flush(cb) { | ||
this.push(exports.closetag); | ||
cb(); | ||
if (!this.hasHeadOutput) { | ||
cb(new errors_1.EmptySitemap()); | ||
} | ||
else { | ||
this.push(exports.closetag); | ||
cb(); | ||
} | ||
} | ||
@@ -91,12 +97,7 @@ } | ||
return new Promise((resolve, reject) => { | ||
let drain; | ||
const drain = []; | ||
stream | ||
.pipe(new stream_1.Writable({ | ||
write(chunk, enc, next) { | ||
if (!drain) { | ||
drain = [chunk]; | ||
} | ||
else { | ||
drain.push(chunk); | ||
} | ||
drain.push(chunk); | ||
next(); | ||
@@ -106,5 +107,12 @@ }, | ||
.on('error', reject) | ||
.on('finish', () => resolve(Buffer.concat(drain))); | ||
.on('finish', () => { | ||
if (!drain.length) { | ||
reject(new errors_1.EmptyStream()); | ||
} | ||
else { | ||
resolve(Buffer.concat(drain)); | ||
} | ||
}); | ||
}); | ||
} | ||
exports.streamToPromise = streamToPromise; |
{ | ||
"name": "sitemap", | ||
"version": "6.1.6", | ||
"version": "6.1.7", | ||
"description": "Sitemap-generating lib/cli", | ||
@@ -29,4 +29,4 @@ "keywords": [ | ||
"prepublishOnly": "rm -rf dist && npm run test", | ||
"test": "eslint lib/* ./cli.ts && tsc && jest && npm run test:xmllint", | ||
"test:fast": "eslint lib/* ./cli.ts && tsc && jest ./tests/sitemap*", | ||
"test": "eslint lib/* ./cli.ts && tsc && jest ./tests/sitemap*", | ||
"test:full": "eslint lib/* ./cli.ts && tsc && jest && npm run test:xmllint", | ||
"test:perf": "node ./tests/perf.js", | ||
@@ -43,3 +43,3 @@ "test:schema": "node tests/alltags.js | xmllint --schema schema/all.xsd --noout -", | ||
"hooks": { | ||
"pre-commit": "lint-staged && npm run test:fast" | ||
"pre-commit": "lint-staged && npm run test" | ||
} | ||
@@ -154,3 +154,3 @@ }, | ||
"dependencies": { | ||
"@types/node": "^14.0.13", | ||
"@types/node": "^14.0.14", | ||
"@types/sax": "^1.2.1", | ||
@@ -161,22 +161,22 @@ "arg": "^4.1.3", | ||
"devDependencies": { | ||
"@babel/core": "^7.10.3", | ||
"@babel/plugin-proposal-class-properties": "^7.10.1", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.1", | ||
"@babel/plugin-proposal-optional-chaining": "^7.10.3", | ||
"@babel/plugin-transform-typescript": "^7.10.3", | ||
"@babel/preset-env": "^7.10.3", | ||
"@babel/preset-typescript": "^7.10.1", | ||
"@types/jest": "^25.2.3", | ||
"@typescript-eslint/eslint-plugin": "^3.3.0", | ||
"@typescript-eslint/parser": "^3.3.0", | ||
"@babel/core": "^7.10.4", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4", | ||
"@babel/plugin-proposal-optional-chaining": "^7.10.4", | ||
"@babel/plugin-transform-typescript": "^7.10.4", | ||
"@babel/preset-env": "^7.10.4", | ||
"@babel/preset-typescript": "^7.10.4", | ||
"@types/jest": "^26.0.3", | ||
"@typescript-eslint/eslint-plugin": "^3.5.0", | ||
"@typescript-eslint/parser": "^3.5.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-polyfill": "^6.26.0", | ||
"concurrently": "^5.2.0", | ||
"eslint": "^7.3.0", | ||
"eslint": "^7.3.1", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-jest": "^23.16.0", | ||
"eslint-plugin-jest": "^23.17.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"express": "^4.17.1", | ||
"husky": "^4.2.5", | ||
"jest": "^26.0.1", | ||
"jest": "^26.1.0", | ||
"lint-staged": "^10.2.11", | ||
@@ -183,0 +183,0 @@ "prettier": "^2.0.5", |
@@ -87,6 +87,7 @@ # sitemap ![MIT License](https://img.shields.io/npm/l/sitemap)[![Build Status](https://travis-ci.org/ekalinin/sitemap.js.svg?branch=master)](https://travis-ci.org/ekalinin/sitemap.js)![Monthly Downloads](https://img.shields.io/npm/dm/sitemap) | ||
smStream.write({ url: '/page-4/', img: "http://urlTest.com" }) | ||
smStream.end() | ||
// cache the response | ||
streamToPromise(pipeline).then(sm => sitemap = sm) | ||
// make sure to attach a write stream such as streamToPromise before ending | ||
smStream.end() | ||
// stream write the response | ||
@@ -125,3 +126,3 @@ pipeline.pipe(res).on('error', (e) => {throw e}) | ||
getSitemapStream: (i) => { | ||
const sitemapStream = new SitemapStream(); | ||
const sitemapStream = new SitemapStream({ hostname: 'https://example.com' }); | ||
const path = `./sitemap-${i}.xml`; | ||
@@ -152,2 +153,3 @@ | ||
arrayOfSitemapItems.forEach(item => sms.write(item)) | ||
sms.end() | ||
``` | ||
@@ -154,0 +156,0 @@ |
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
146868
2680
250
Updated@types/node@^14.0.14