refactor(compiler): remove dependency on fs-extra (#41445)

Currently, fs-extra is used to delete a directory recursively, but this is already available in native Node.JS. Hence, making this dependency redundant.

See: https://nodejs.org/docs/latest-v12.x/api/fs.html

PR Close #41445
This commit is contained in:
Alan Agius
2021-04-04 18:06:02 +02:00
committed by atscott
parent 44e7865698
commit 3a823abcc5
10 changed files with 4 additions and 31 deletions
-1
View File
@@ -41,7 +41,6 @@ ts_library(
"@npm//@bazel/typescript",
"@npm//@types/node",
"@npm//chokidar",
"@npm//fs-extra",
"@npm//minimist",
"@npm//reflect-metadata",
"@npm//tsickle",
@@ -31,7 +31,6 @@ nodejs_test(
"@nodejs//:node",
"@npm//domino",
"@npm//chokidar",
"@npm//fs-extra",
"@npm//source-map-support",
"@npm//shelljs",
"@npm//typescript",
@@ -46,7 +46,6 @@ const requiredNodeModules = {
'tslib': resolveNpmTreeArtifact('npm/node_modules/tslib'),
'domino': resolveNpmTreeArtifact('npm/node_modules/domino'),
'xhr2': resolveNpmTreeArtifact('npm/node_modules/xhr2'),
'fs-extra': resolveNpmTreeArtifact('npm/node_modules/fs-extra'),
// Fine grained dependencies which are used by the integration test Angular modules, and
// need to be symlinked so that they can be resolved by NodeJS or NGC.
-1
View File
@@ -19,7 +19,6 @@
"chokidar": "^3.0.0",
"convert-source-map": "^1.5.1",
"dependency-graph": "^0.7.2",
"fs-extra": "4.0.2",
"magic-string": "^0.25.0",
"semver": "^6.3.0",
"source-map": "^0.6.1",
@@ -8,9 +8,7 @@ ts_library(
"src/**/*.ts",
]),
deps = [
"@npm//@types/fs-extra",
"@npm//@types/node",
"@npm//fs-extra",
"@npm//typescript",
],
)
@@ -7,7 +7,6 @@
*/
/// <reference types="node" />
import * as fs from 'fs';
import * as fsExtra from 'fs-extra';
import * as p from 'path';
import {AbsoluteFsPath, FileStats, FileSystem, PathManipulation, PathSegment, PathString, ReadonlyFileSystem} from './types';
@@ -121,7 +120,7 @@ export class NodeJSFileSystem extends NodeJSReadonlyFileSystem implements FileSy
}
}
removeDeep(path: AbsoluteFsPath): void {
fsExtra.removeSync(path);
fs.rmdirSync(path, {recursive: true});
}
private safeMkdir(path: AbsoluteFsPath): void {
@@ -11,7 +11,6 @@ ts_library(
deps = [
"//packages/compiler-cli/src/ngtsc/file_system",
"//packages/compiler-cli/src/ngtsc/file_system/testing",
"@npm//@types/fs-extra",
"@npm//typescript",
],
)
@@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import * as realFs from 'fs';
import * as fsExtra from 'fs-extra';
import * as os from 'os';
import {NodeJSFileSystem, NodeJSPathManipulation, NodeJSReadonlyFileSystem} from '../src/node_js_file_system';
import {AbsoluteFsPath, PathSegment} from '../src/types';
@@ -269,10 +268,10 @@ describe('NodeJSFileSystem', () => {
});
describe('removeDeep()', () => {
it('should delegate to fsExtra.remove()', () => {
const spy = spyOn(fsExtra, 'removeSync');
it('should delegate to rmdirSync()', () => {
const spy = spyOn(realFs, 'rmdirSync');
fs.removeDeep(abcPath);
expect(spy).toHaveBeenCalledWith(abcPath);
expect(spy).toHaveBeenCalledWith(abcPath, {recursive: true});
});
});
});