Skip to content

Commit 405b22e

Browse files
committed
refactor: use fs/promises instead of rimraf package
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.
1 parent 6345642 commit 405b22e

File tree

5 files changed

+21
-136
lines changed

5 files changed

+21
-136
lines changed

actions/build.action.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getWebpackConfigPath } from '../lib/compiler/helpers/get-webpack-config
1010
import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider';
1111
import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader';
1212
import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader';
13-
import { WorkspaceUtils } from '../lib/compiler/workspace-utils';
13+
import { deleteOutDirIfEnabled } from '../lib/compiler/helpers/delete-out-dir';
1414
import {
1515
Configuration,
1616
ConfigurationLoader,
@@ -34,7 +34,6 @@ export class BuildAction extends AbstractAction {
3434
this.fileSystemReader,
3535
);
3636
protected readonly assetsManager = new AssetsManager();
37-
protected readonly workspaceUtils = new WorkspaceUtils();
3837

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

104-
await this.workspaceUtils.deleteOutDirIfEnabled(
105-
configuration,
106-
appName,
107-
outDir,
108-
);
103+
await deleteOutDirIfEnabled(configuration, appName, outDir);
109104
this.assetsManager.copyAssets(
110105
configuration,
111106
appName,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { rm } from 'fs/promises';
2+
import { Configuration } from '../../configuration';
3+
import { getValueOrDefault } from './get-value-or-default';
4+
5+
export async function deleteOutDirIfEnabled(
6+
configuration: Required<Configuration>,
7+
appName: string,
8+
dirPath: string,
9+
) {
10+
const isDeleteEnabled = getValueOrDefault<boolean>(
11+
configuration,
12+
'compilerOptions.deleteOutDir',
13+
appName,
14+
);
15+
if (!isDeleteEnabled) {
16+
return;
17+
}
18+
await rm(dirPath, { recursive: true, force: true });
19+
}

lib/compiler/workspace-utils.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

package-lock.json

Lines changed: 0 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"inquirer": "8.2.6",
5252
"node-emoji": "1.11.0",
5353
"ora": "5.4.1",
54-
"rimraf": "4.4.1",
5554
"shelljs": "0.8.5",
5655
"source-map-support": "0.5.21",
5756
"tree-kill": "1.2.2",

0 commit comments

Comments
 (0)