Repository: webpack-contrib/copy-webpack-plugin
Pull request #336 (2019-02-18 17:02:17)

refactor: use `Error` class for error
<!--
  HOLY CRAP a Pull Request. We ❤️ those!

  If you remove or skip this template, you'll make the 🐼 sad and the mighty god
  of Github will appear and pile-drive the close button from a great height
  while making animal noises.

  Please place an x (no spaces!) in all [ ] that apply
-->

This PR contains a:

- [ ] **bugfix**
- [ ] new **feature**
- [x] **code refactor**
- [ ] **test update** <!-- if bug or feature is checked, this should be too -->
- [ ] **typo fix**
- [ ] **metadata update**

### Motivation / Use-Case

use new `Error`

### Breaking Changes

No

### Additional Info

No

codecov[bot]: # [Codecov](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@49a28f0`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336/graphs/tree.svg?width=650&token=fEoU9iBFGL&height=150&src=pr)](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master     #336   +/-   ##
=========================================
  Coverage          ?   95.23%           
=========================================
  Files             ?        8           
  Lines             ?      273           
  Branches          ?       73           
=========================================
  Hits              ?      260           
  Misses            ?       12           
  Partials          ?        1
```


| [Impacted Files](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/processPattern.js](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336/diff?src=pr&el=tree#diff-c3JjL3Byb2Nlc3NQYXR0ZXJuLmpz) | `97.87% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336?src=pr&el=footer). Last update [49a28f0...e5da34a](https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/pull/336?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/processPattern.js b/src/processPattern.js
index 289f0ee..4e911af 100644
--- a/src/processPattern.js
+++ b/src/processPattern.js
@@ -97,8 +97,9 @@ export default function processPattern(globalRef, pattern) {
 
           if (path.isAbsolute(file.webpackTo)) {
             if (output === '/') {
-              // eslint-disable-next-line no-throw-literal
-              throw '[copy-webpack-plugin] Using older versions of webpack-dev-server, devServer.outputPath must be defined to write to absolute paths';
+              throw new Error(
+                '[copy-webpack-plugin] Using older versions of webpack-dev-server, devServer.outputPath must be defined to write to absolute paths'
+              );
             }
 
             file.webpackTo = path.relative(output, file.webpackTo);


Test patch:
diff --git a/test/CopyPlugin.test.js b/test/CopyPlugin.test.js
index a332750..b326bc3 100644
--- a/test/CopyPlugin.test.js
+++ b/test/CopyPlugin.test.js
@@ -857,8 +857,9 @@ describe('apply function', () => {
         }),
         expectedAssetKeys: [],
         expectedErrors: [
-          '[copy-webpack-plugin] Using older versions of webpack-dev-server, devServer.outputPath must be ' +
-            'defined to write to absolute paths',
+          new Error(
+            '[copy-webpack-plugin] Using older versions of webpack-dev-server, devServer.outputPath must be defined to write to absolute paths'
+          ),
         ],
         patterns: [
           {