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

serverless-heaven / serverless-webpack / 8625336483

10 Apr 2024 03:01AM UTC coverage: 92.927% (-0.4%) from 93.361%
8625336483

push

github

web-flow
Merge pull request #1771 from serverless-heaven/dependabot/npm_and_yarn/examples/include-external-npm-packages-with-yarn-workspaces/tar-6.2.1

565 of 634 branches covered (89.12%)

Branch coverage included in aggregate %.

2562 of 2731 relevant lines covered (93.81%)

53.56 hits per line

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

89.6
/lib/Configuration.js
1
'use strict';
1✔
2
/**
1✔
3
 * Plugin configuration.
1✔
4
 */
1✔
5

1✔
6
const _ = require('lodash');
1✔
7
const os = require('os');
1✔
8

1✔
9
/**
1✔
10
 * Plugin defaults
1✔
11
 */
1✔
12
const DefaultConfig = {
1✔
13
  webpackConfig: 'webpack.config.js',
1✔
14
  includeModules: false,
1✔
15
  packager: 'npm',
1✔
16
  packagerOptions: {},
1✔
17
  keepOutputDirectory: false,
1✔
18
  config: null,
1✔
19
  concurrency: os.cpus().length
1✔
20
};
1✔
21

1✔
22
class Configuration {
1✔
23
  constructor(custom) {
1✔
24
    this._config = {};
98✔
25
    this._hasLegacyConfig = false;
98✔
26

98✔
27
    // Set configuration from sls.service.custom. We fall back to the
98✔
28
    // old configuration to keep backwards compatibility.
98✔
29
    if (custom) {
98✔
30
      if (custom.webpackIncludeModules) {
83!
31
        this._config.includeModules = custom.webpackIncludeModules;
×
32
        this._hasLegacyConfig = true;
×
33
      }
×
34
      if (_.isString(custom.webpack)) {
83✔
35
        this._config.webpackConfig = custom.webpack;
7✔
36
        this._hasLegacyConfig = true;
7✔
37
      } else {
83✔
38
        _.assign(this._config, custom.webpack || {});
76✔
39
      }
76✔
40
    }
83✔
41

98✔
42
    // Concurrency may be passed via CLI, e.g.
98✔
43
    // custom:
98✔
44
    //   webpack:
98✔
45
    //     concurrency: ${opt:compile-concurrency, 7}
98✔
46
    // In this case it is typed as a string and we have to validate it
98✔
47
    if (this._config.concurrency !== undefined) {
98!
48
      this._config.concurrency = Number(this._config.concurrency);
×
49
      if (isNaN(this._config.concurrency) || this._config.concurrency < 1) {
×
50
        throw new Error('concurrency option must be a positive number');
×
51
      }
×
52
    } else if (this._config.serializedCompile === true) {
98!
53
      // Backwards compatibility with serializedCompile setting
×
54
      this._config.concurrency = 1;
×
55
    }
×
56

98✔
57
    // Set defaults for all missing properties
98✔
58
    _.defaults(this._config, DefaultConfig);
98✔
59
  }
98✔
60

1✔
61
  get webpackConfig() {
1✔
62
    return this._config.webpackConfig;
12✔
63
  }
12✔
64

1✔
65
  get includeModules() {
1✔
66
    return this._config.includeModules;
29✔
67
  }
29✔
68

1✔
69
  get excludeFiles() {
1✔
70
    return this._config.excludeFiles;
41✔
71
  }
41✔
72

1✔
73
  get excludeRegex() {
1✔
74
    return this._config.excludeRegex;
26✔
75
  }
26✔
76

1✔
77
  get packager() {
1✔
78
    return this._config.packager;
26✔
79
  }
26✔
80

1✔
81
  get packagerOptions() {
1✔
82
    return this._config.packagerOptions;
145✔
83
  }
145✔
84

1✔
85
  get config() {
1✔
86
    return this._config.config;
45✔
87
  }
45✔
88

1✔
89
  get hasLegacyConfig() {
1✔
90
    return this._hasLegacyConfig;
48✔
91
  }
48✔
92

1✔
93
  get keepOutputDirectory() {
1✔
94
    return this._config.keepOutputDirectory;
8✔
95
  }
8✔
96

1✔
97
  get concurrency() {
1✔
98
    return this._config.concurrency;
5✔
99
  }
5✔
100

1✔
101
  toJSON() {
1✔
102
    return _.omitBy(this._config, _.isNil);
4✔
103
  }
4✔
104
}
1✔
105

1✔
106
module.exports = Configuration;
1✔
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