src/clean-webpack-plugin.ts
changed.
Other files ignored by Codecov
README.md
has changed.
62 | 62 | dangerouslyAllowCleanPatternsOutsideProject?: boolean; |
|
63 | 63 | } |
|
64 | 64 | ||
65 | + | // Copied from https://github.com/sindresorhus/is-plain-obj/blob/97480673cf12145b32ec2ee924980d66572e8a86/index.js |
|
66 | + | function isPlainObject(value: unknown): boolean { |
|
67 | + | if (Object.prototype.toString.call(value) !== '[object Object]') { |
|
68 | + | return false; |
|
69 | + | } |
|
70 | + | ||
71 | + | const prototype = Object.getPrototypeOf(value); |
|
72 | + | return prototype === null || prototype === Object.getPrototypeOf({}); |
|
73 | + | } |
|
74 | + | ||
65 | 75 | class CleanWebpackPlugin { |
|
66 | 76 | private readonly dry: boolean; |
|
67 | 77 | private readonly verbose: boolean; |
75 | 85 | private outputPath: string; |
|
76 | 86 | ||
77 | 87 | constructor(options: Options = {}) { |
|
78 | - | if (Object.prototype.toString.call(options) !== "[object Object]") { |
|
88 | + | if (isPlainObject(options) === false) { |
|
79 | 89 | throw new Error(`clean-webpack-plugin only accepts an options object. See: |
|
80 | 90 | https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optional`); |
|
81 | 91 | } |
Files | Coverage |
---|---|
src/clean-webpack-plugin.ts | 98.78% |
Project Totals (1 files) | 98.78% |