Skip to content

Commit

Permalink
Update @jwilsson/tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed May 13, 2022
1 parent 7c8c132 commit 2337dfe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@jwilsson/eslint-config-prettier": "^7.1.0",
"@jwilsson/eslint-config-typescript": "^7.1.0",
"@jwilsson/prettier-config": "^7.2.0",
"@jwilsson/tsconfig": "^1.1.0",
"@jwilsson/tsconfig": "^1.3.0",
"@types/jest": "^27.0.1",
"esbuild": "^0.14.0",
"eslint": "^8.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/CleanPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import del from 'del';
import { BuildOptions, BuildResult } from 'esbuild';
import { type BuildOptions, type BuildResult } from 'esbuild';
import path from 'node:path';

export interface PluginOptions {
export type PluginOptions = {
dry?: boolean;
initialCleanPatterns?: string[];
verbose?: boolean;
}
};

export class CleanPlugin {
private previousAssets: string[] = [];
Expand Down
9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Plugin } from 'esbuild';
import { type Plugin } from 'esbuild';
import { CleanPlugin, type PluginOptions } from './CleanPlugin.js';

import { CleanPlugin, PluginOptions } from './CleanPlugin.js';

export { PluginOptions } from './CleanPlugin.js';
export { type PluginOptions } from './CleanPlugin.js';

export const cleanPlugin = (pluginOptions: PluginOptions = {}): Plugin => {
return {
name: 'clean',
setup(build) {
setup(build): void {
const plugin = new CleanPlugin(pluginOptions, build.initialOptions);

if (plugin.validateOptions()) {
Expand Down
15 changes: 7 additions & 8 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { build, BuildOptions } from 'esbuild';
import { jest } from '@jest/globals';
import tempy from 'tempy';
import path from 'path';
import { build, type BuildOptions, type BuildResult } from 'esbuild';
import fs from 'fs';
import path from 'path';
import tempy from 'tempy';
import { cleanPlugin, type PluginOptions } from '../src';

import { cleanPlugin, PluginOptions } from '../src';

const filesExists = (filePath: string, fileNames: string[]) => {
const filesExists = (filePath: string, fileNames: string[]): boolean => {
return fileNames.every((fileName) => {
fileName = path.resolve(filePath, fileName);

return fs.existsSync(fileName);
});
};

const writeFile = (filePath: string, fileName: string, data = '') => {
const writeFile = (filePath: string, fileName: string, data = ''): void => {
fileName = path.resolve(filePath, fileName);

fs.writeFileSync(fileName, data);
Expand All @@ -23,7 +22,7 @@ const writeFile = (filePath: string, fileName: string, data = '') => {
const runBuild = (
buildOptions: BuildOptions = {},
pluginOptions?: PluginOptions,
) => {
): Promise<BuildResult> => {
return build({
metafile: true,
plugins: [cleanPlugin(pluginOptions)],
Expand Down

0 comments on commit 2337dfe

Please sign in to comment.