• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hexojs / hexo / 26276472383

22 May 2026 08:13AM UTC coverage: 99.362%. First build
26276472383

Pull #5731

github

web-flow
Merge e68c1f71f into 03c55048c
Pull Request #5731: feat(validate_config): add warning about timezone

2441 of 2540 branches covered (96.1%)

6 of 20 new or added lines in 1 file covered. (30.0%)

9974 of 10038 relevant lines covered (99.36%)

59.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.21
/lib/hexo/validate_config.ts
1
import assert from 'assert';
1✔
2
import moment from 'moment-timezone';
1✔
3
import type Hexo from './index';
1✔
4

1✔
5
export = (ctx: Hexo): void => {
1✔
6
  const { config, log } = ctx;
24✔
7

24✔
8
  log.info('Validating config');
24✔
9

24✔
10
  // Validation for config.url && config.root
24✔
11
  if (typeof config.url !== 'string') {
24✔
12
    throw new TypeError(`Invalid config detected: "url" should be string, not ${typeof config.url}!`);
2✔
13
  }
2✔
14
  try {
22✔
15
    // eslint-disable-next-line no-new
22✔
16
    new URL(config.url);
22✔
17
    assert(new URL(config.url).protocol.startsWith('http'));
22✔
18
  } catch {
24✔
19
    throw new TypeError('Invalid config detected: "url" should be a valid URL!');
3✔
20
  }
3✔
21

19✔
22
  if (typeof config.root !== 'string') {
24✔
23
    throw new TypeError(`Invalid config detected: "root" should be string, not ${typeof config.root}!`);
2✔
24
  }
2✔
25
  if (config.root.trim().length <= 0) {
24✔
26
    throw new TypeError('Invalid config detected: "root" should not be empty!');
1✔
27
  }
1✔
28

16✔
29
  if (!config.timezone) {
16✔
30
    log.warn('No timezone setting detected! Using LocalTimeZone as the default timezone.');
16✔
31
    log.warn('This behavior will be changed to UTC in the next major version. Please set timezone explicitly (e.g. LocalTimeZone or America/New_York) in _config.yml to avoid this warning.');
16✔
32
  } else {
24!
NEW
33
    const configTimezone = moment.tz.zone(config.timezone);
×
NEW
34
    if (!configTimezone) {
×
NEW
35
      log.warn(
×
NEW
36
        `Invalid timezone setting detected! "${config.timezone}" is not a valid timezone.`
×
NEW
37
      );
×
NEW
38
    } else {
×
NEW
39
      const machineTimezone = moment.tz.guess();
×
NEW
40
      if (configTimezone.name !== machineTimezone) {
×
NEW
41
        log.warn(
×
NEW
42
          `The timezone "${config.timezone}" setting is different from your machine timezone "${machineTimezone}". Make sure this is intended.`
×
NEW
43
        );
×
NEW
44
      }
×
NEW
45
    }
×
NEW
46
  }
×
47
};
24✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc