Skip to content

Commit 94a9952

Browse files
committed
refactor(@angular/cli): change workspace host to use async Node APIs
1 parent 811487f commit 94a9952

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/angular/cli/src/utilities/config.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { json, workspaces } from '@angular-devkit/core';
10-
import { existsSync, readFileSync, statSync, writeFileSync } from 'fs';
10+
import { existsSync, promises as fs, writeFileSync } from 'fs';
1111
import * as os from 'os';
1212
import * as path from 'path';
1313
import { PackageManager } from '../../lib/config/workspace-schema';
@@ -20,22 +20,26 @@ function isJsonObject(value: json.JsonValue | undefined): value is json.JsonObje
2020

2121
function createWorkspaceHost(): workspaces.WorkspaceHost {
2222
return {
23-
async readFile(path) {
24-
return readFileSync(path, 'utf-8');
23+
readFile(path) {
24+
return fs.readFile(path, 'utf-8');
2525
},
2626
async writeFile(path, data) {
27-
writeFileSync(path, data);
27+
await fs.writeFile(path, data);
2828
},
2929
async isDirectory(path) {
3030
try {
31-
return statSync(path).isDirectory();
31+
const stats = await fs.stat(path);
32+
33+
return stats.isDirectory();
3234
} catch {
3335
return false;
3436
}
3537
},
3638
async isFile(path) {
3739
try {
38-
return statSync(path).isFile();
40+
const stats = await fs.stat(path);
41+
42+
return stats.isFile();
3943
} catch {
4044
return false;
4145
}

0 commit comments

Comments
 (0)