Skip to content

Commit

Permalink
refactor: use fs/promises instead of rimraf package
Browse files Browse the repository at this point in the history
refactor to use the `rm()` method instead of the `rimraf` package. Also moved the `deleteOutDirIfEnabled()` method from the WorkspaceUtils class into its own file inside the helper directory because it is the only method of the class.
  • Loading branch information
Phillip9587 committed Feb 24, 2024
1 parent aca4ad2 commit d82a8ae
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 136 deletions.
9 changes: 2 additions & 7 deletions actions/build.action.ts
Expand Up @@ -10,7 +10,7 @@ import { getWebpackConfigPath } from '../lib/compiler/helpers/get-webpack-config
import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider';
import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader';
import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader';
import { WorkspaceUtils } from '../lib/compiler/workspace-utils';
import { deleteOutDirIfEnabled } from '../lib/compiler/helpers/delete-out-dir';
import {
Configuration,
ConfigurationLoader,
Expand All @@ -34,7 +34,6 @@ export class BuildAction extends AbstractAction {
this.fileSystemReader,
);
protected readonly assetsManager = new AssetsManager();
protected readonly workspaceUtils = new WorkspaceUtils();

public async handle(commandInputs: Input[], commandOptions: Input[]) {
try {
Expand Down Expand Up @@ -101,11 +100,7 @@ export class BuildAction extends AbstractAction {
? { type: 'webpack' }
: getBuilder(configuration, commandOptions, appName);

await this.workspaceUtils.deleteOutDirIfEnabled(
configuration,
appName,
outDir,
);
await deleteOutDirIfEnabled(configuration, appName, outDir);
this.assetsManager.copyAssets(
configuration,
appName,
Expand Down
19 changes: 19 additions & 0 deletions lib/compiler/helpers/delete-out-dir.ts
@@ -0,0 +1,19 @@
import { rm } from 'fs/promises';
import { Configuration } from '../../configuration';
import { getValueOrDefault } from './get-value-or-default';

export async function deleteOutDirIfEnabled(
configuration: Required<Configuration>,
appName: string,
dirPath: string,
) {
const isDeleteEnabled = getValueOrDefault<boolean>(
configuration,
'compilerOptions.deleteOutDir',
appName,
);
if (!isDeleteEnabled) {
return;
}
await rm(dirPath, { recursive: true, force: true });
}
21 changes: 0 additions & 21 deletions lib/compiler/workspace-utils.ts

This file was deleted.

107 changes: 0 additions & 107 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -51,7 +51,6 @@
"inquirer": "8.2.6",
"node-emoji": "1.11.0",
"ora": "5.4.1",
"rimraf": "4.4.1",
"shelljs": "0.8.5",
"source-map-support": "0.5.21",
"tree-kill": "1.2.2",
Expand Down

0 comments on commit d82a8ae

Please sign in to comment.