Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit 6f42ecb

Browse files
authored
Merge pull request #19 from ItsNickBarry/hardhat-error-constructor
replace deprecated HardhatPluginError constructor
2 parents 52186a5 + 7715d2c commit 6f42ecb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tasks/compile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs');
22
const path = require('path');
33
const { HardhatPluginError } = require('hardhat/plugins');
4+
const { name: PLUGIN_NAME } = require('../package.json');
45

56
const {
67
TASK_COMPILE,
@@ -26,19 +27,19 @@ task(TASK_COMPILE, async function (args, hre, runSuper) {
2627
const tracker = path.resolve(directory, `.${ name }`);
2728

2829
if (!directory.startsWith(sources)) {
29-
throw new HardhatPluginError('resolved path must be inside of sources directory');
30+
throw new HardhatPluginError(PLUGIN_NAME, 'resolved path must be inside of sources directory');
3031
}
3132

3233
if (directory === sources) {
33-
throw new HardhatPluginError('resolved path must not be sources directory');
34+
throw new HardhatPluginError(PLUGIN_NAME, 'resolved path must not be sources directory');
3435
}
3536

3637
if (fs.existsSync(directory)) {
3738
// delete directory only if tracker is found or directory is empty
3839
if (fs.existsSync(tracker) || fs.readdirSync(directory).length == 0) {
3940
fs.rmSync(directory, { recursive: true });
4041
} else {
41-
throw new HardhatPluginError(`temporary source directory must have been generated by ${ name }`);
42+
throw new HardhatPluginError(PLUGIN_NAME, `temporary source directory must have been generated by ${ name }`);
4243
}
4344
}
4445

0 commit comments

Comments
 (0)