Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed used of fs-extra from @tryghost/logging #140

Merged
merged 2 commits into from Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/errors/src/errors.ts
Expand Up @@ -137,6 +137,17 @@ export class RequestNotAcceptableError extends GhostError {
}
}

export class RangeNotSatisfiableError extends GhostError {
constructor(options: GhostErrorOptions = {}) {
super(mergeOptions(options, {
statusCode: 416,
errorType: 'RangeNotSatisfiableError',
message: 'Range not satisfiable for provided Range header.',
hideStack: true
}));
}
}

export class RequestEntityTooLargeError extends GhostError {
constructor(options: GhostErrorOptions = {}) {
super(mergeOptions(options, {
Expand Down
9 changes: 9 additions & 0 deletions packages/errors/test/errors.test.ts
Expand Up @@ -488,6 +488,15 @@ Line 2 - Help`);
error.hideStack.should.be.false();
});

it('RangeNotSatisfiableError', function () {
const error = new errors.RangeNotSatisfiableError();
error.statusCode.should.eql(416);
error.level.should.eql('normal');
error.errorType.should.eql('RangeNotSatisfiableError');
error.message.should.eql('Range not satisfiable for provided Range header.');
error.hideStack.should.be.true();
});

it('TokenRevocationError', function () {
const error = new errors.TokenRevocationError();
error.statusCode.should.eql(503);
Expand Down
4 changes: 2 additions & 2 deletions packages/logging/lib/GhostLogger.js
Expand Up @@ -5,7 +5,7 @@ const isObject = require('lodash/isObject');
const isEmpty = require('lodash/isEmpty');
const includes = require('lodash/includes');
const bunyan = require('bunyan');
const fs = require('fs-extra');
const fs = require('fs');
const jsonStringifySafe = require('json-stringify-safe');

/**
Expand Down Expand Up @@ -287,7 +287,7 @@ class GhostLogger {
const sanitizedDomain = this.domain.replace(/[^\w]/gi, '_');

// CASE: target log folder does not exist, show warning
if (!fs.pathExistsSync(this.path)) {
if (!fs.existsSync(this.path)) {
this.error('Target log folder does not exist: ' + this.path);
return;
}
Expand Down