feat(progress-bar-webpack-plugin): new type definition (#43069)

- definition file
- tests

https://github.com/clessg/progress-bar-webpack-plugin#readme
https://github.com/clessg/progress-bar-webpack-plugin#options

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-03-27 18:21:49 +01:00 committed by GitHub
parent 0f432e3ad0
commit fe0fce11ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,44 @@
// Type definitions for progress-bar-webpack-plugin 2.1
// Project: https://github.com/clessg/progress-bar-webpack-plugin#readme
// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as ProgressBar from 'progress';
import { Plugin } from 'webpack';
export = ProgressBarPlugin;
declare namespace ProgressBarPlugin {
interface Options extends ProgressBar.ProgressBarOptions {
/**
* the format of the progress bar
* @default ':bar'
*/
format?: string;
/**
* optional function to call when the progress bar completes
*/
callback?: () => void;
/**
* option to show summary of time taken
* @default true
*/
summary?: boolean;
/**
* custom summary message if summary option is false
*/
summaryContent?: boolean;
/**
* function to display a custom summary
* (passed build time)
*/
customSummary?: (summary: string) => void;
}
}
/**
* A progress bar plugin for Webpack.
*/
declare class ProgressBarPlugin extends Plugin {
constructor(options?: ProgressBarPlugin.Options);
}

View File

@ -0,0 +1,24 @@
import ProgressBarPlugin = require('progress-bar-webpack-plugin');
import webpack = require('webpack');
const configuration: webpack.Configuration = {
plugins: [
new ProgressBarPlugin({
total: 10,
format: ` build [:bar] ... (:elapsed seconds)`,
clear: false,
callback: () => {
console.log('done');
},
complete: '=',
curr: 2,
incomplete: ' ',
width: 20,
customSummary: summary => {
console.log(summary);
// rest of the code ...
},
}),
],
};
webpack(configuration);

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"progress-bar-webpack-plugin-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }