Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-roll

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-roll - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

6

lib/utils.js

@@ -5,3 +5,3 @@ 'use strict'

const { dirname, join } = require('path')
const { format } = require('date-fns')
const { format, addDays, addHours } = require('date-fns')

@@ -57,7 +57,7 @@ function parseSize (size) {

function getNextDay (start) {
return new Date(start + 24 * 60 * 60 * 1000).setHours(0, 0, 0, 0)
return addDays(new Date(start), 1).setHours(0, 0, 0, 0)
}
function getNextHour (start) {
return new Date(start + 60 * 60 * 1000).setMinutes(0, 0, 0)
return addHours(new Date(start), 1).setMinutes(0, 0, 0)
}

@@ -64,0 +64,0 @@

{
"name": "pino-roll",
"version": "2.1.0",
"version": "2.2.0",
"description": "A Pino transport that automatically rolls your log files",

@@ -31,2 +31,3 @@ "main": "pino-roll.js",

"husky": "^9.0.11",
"mockdate": "^3.0.5",
"pino": "^9.2.0",

@@ -33,0 +34,0 @@ "snazzy": "^9.0.0",

@@ -8,2 +8,3 @@ 'use strict'

const { format } = require('date-fns')
const MockDate = require('mockdate')

@@ -73,2 +74,62 @@ const {

test('getNext() on dates transitioning from DST to Standard Time', async ({ same }) => {
// on these days the time rolls back 1 hour so there "are" 25 hours in the day
// genNext() should account for variable number of hours in the day
// test two different timezones
const data = [
{
tz: 'Europe/Berlin',
mockDate: '27 Oct 2024 00:00:00 GMT+0100'
},
{
tz: 'America/New_York',
mockDate: '03 Nov 2024 00:00:00 GMT-0500'
}
]
for (const d of data) {
MockDate.set(d.mockDate)
process.env.TZ = d.tz
const today = new Date()
same(getNext('daily'), startOfDay(addDays(today, 1)).getTime(), 'supports daily frequency')
same(getNext('hourly'), startOfHour(addHours(today, 1)).getTime(), 'supports hourly frequency')
const custom = 3000
same(getNext(custom), Date.now() + custom, 'supports custom frequency and does not return start')
MockDate.reset()
process.env.TZ = undefined
}
})
test('getNext() on dates transitioning from Standard Time to DST', async ({ same }) => {
// on these days the time rolls forward 1 hour so there "are" 23 hours in the day
// genNext() should account for variable number of hours in the day
// test two different timezones
const data = [
{
tz: 'Europe/Berlin',
mockDate: '31 March 2024 01:00:00 GMT+0100'
},
{
tz: 'America/New_York',
mockDate: '10 Nov 2024 01:00:00 GMT-0500'
}
]
for (const d of data) {
MockDate.set(d.mockDate)
process.env.TZ = d.tz
const today = new Date()
same(getNext('daily'), startOfDay(addDays(today, 1)).getTime(), 'supports daily frequency')
same(getNext('hourly'), startOfHour(addHours(today, 1)).getTime(), 'supports hourly frequency')
const custom = 3000
same(getNext(custom), Date.now() + custom, 'supports custom frequency and does not return start')
MockDate.reset()
process.env.TZ = undefined
}
})
test('getFileName()', async ({ equal, throws }) => {

@@ -75,0 +136,0 @@ const strFunc = () => 'my-func'

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc