diff --git a/config/webpack/CustomVersionFilePlugin.ts b/config/webpack/CustomVersionFilePlugin.ts index 4003429341c6..fc19d8543599 100644 --- a/config/webpack/CustomVersionFilePlugin.ts +++ b/config/webpack/CustomVersionFilePlugin.ts @@ -1,6 +1,7 @@ +import type * as FS from 'fs'; import type {Compiler} from 'webpack'; -const fs = require('fs'); +const fs = require('fs') as typeof FS; const path = require('path'); const APP_VERSION = require('../../package.json').version; @@ -9,27 +10,16 @@ const APP_VERSION = require('../../package.json').version; */ class CustomVersionFilePlugin { apply(compiler: Compiler) { - compiler.hooks.done.tap( - this.constructor.name, - () => - new Promise((resolve, reject) => { - const versionPath = path.join(__dirname, '/../../dist/version.json'); - fs.mkdir(path.dirname(versionPath), {recursive: true}, (dirErr) => { - if (dirErr) { - reject(dirErr); - return; - } - fs.writeFile(versionPath, JSON.stringify({version: APP_VERSION}), 'utf8', (fileErr) => { - if (fileErr) { - reject(fileErr); - return; - } - resolve(); - }); - }); - }), - ); + compiler.hooks.done.tap(this.constructor.name, () => { + const versionPath = path.join(__dirname, '/../../dist/version.json'); + fs.mkdir(path.dirname(versionPath), {recursive: true}, (dirErr) => { + if (dirErr) { + return; + } + fs.writeFile(versionPath, JSON.stringify({version: APP_VERSION}), {encoding: 'utf8'}, () => {}); + }); + }); } } -export default CustomVersionFilePlugin; +export = CustomVersionFilePlugin;