Skip to content

Commit 4344ef8

Browse files
committed
Remove use of fsx from the new gcb-TS tasks.
1 parent 85fa448 commit 4344ef8

4 files changed

Lines changed: 16 additions & 15 deletions

File tree

‎core-build/gulp-core-build-typescript/src/ApiExtractorBaseTask.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as fsx from 'fs-extra';
54
import * as Gulp from 'gulp';
65
import * as path from 'path';
76
import { GulpTask } from '@microsoft/gulp-core-build';
7+
import { FileSystem } from '@microsoft/node-core-library';
88
import {
99
Extractor,
1010
IExtractorOptions,
@@ -218,7 +218,7 @@ export abstract class ApiExtractorBaseTask extends GulpTask<IApiExtractorTaskCon
218218
return false;
219219
}
220220

221-
if (!fsx.existsSync(this.taskConfig.entry)) {
221+
if (!FileSystem.exists(this.taskConfig.entry)) {
222222
this.logError(`Entry file ${this.taskConfig.entry} does not exist.`);
223223
return false;
224224
}

‎core-build/gulp-core-build-typescript/src/ApiExtractorTask.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as fsx from 'fs-extra';
54
import * as path from 'path';
65
import * as ts from 'typescript';
76
import {
87
Extractor,
98
IExtractorOptions,
109
IExtractorConfig
1110
} from '@microsoft/api-extractor';
12-
import { TypeScriptConfiguration } from './TypeScriptConfiguration';
1311
import gulpTypeScript = require('gulp-typescript');
12+
import { FileSystem } from '@microsoft/node-core-library';
1413

14+
import { TypeScriptConfiguration } from './TypeScriptConfiguration';
1515
import { ApiExtractorBaseTask } from './ApiExtractorBaseTask';
1616

1717
/**
@@ -23,7 +23,7 @@ import { ApiExtractorBaseTask } from './ApiExtractorBaseTask';
2323
export class ApiExtractorTask extends ApiExtractorBaseTask {
2424
protected updateExtractorOptions(extractorOptions: IExtractorOptions, entryPointFile: string): void {
2525
const typingsFilePath: string = path.join(this.buildConfig.rootPath, 'typings/tsd.d.ts');
26-
const otherFiles: string[] = fsx.existsSync(typingsFilePath) ? [typingsFilePath] : [];
26+
const otherFiles: string[] = FileSystem.exists(typingsFilePath) ? [typingsFilePath] : [];
2727

2828
// tslint:disable-next-line:no-any
2929
const gulpTypeScriptSettings: gulpTypeScript.Settings =

‎core-build/gulp-core-build-typescript/src/miniTasks/BaseCmdTask.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
import * as childProcess from 'child_process';
55
import * as path from 'path';
6-
import * as fsx from 'fs-extra';
76

87
import {
98
JsonFile,
10-
IPackageJson
9+
IPackageJson,
10+
FileSystem
1111
} from '@microsoft/node-core-library';
1212
import { GulpTask } from '@microsoft/gulp-core-build';
1313

@@ -69,7 +69,7 @@ export abstract class BaseCmdTask<TTaskConfig extends IBaseCmdTaskConfig> extend
6969
public executeTask(gulp: Object, completeCallback: (error?: string) => void): Promise<void> | undefined {
7070
let binaryPackagePath: string = require.resolve(this._packageName);
7171
let packageJsonPath: string;
72-
while (!fsx.existsSync(packageJsonPath = path.join(binaryPackagePath, 'package.json'))) {
72+
while (!FileSystem.exists(packageJsonPath = path.join(binaryPackagePath, 'package.json'))) {
7373
const tempBinaryPackagePath: string = path.dirname(binaryPackagePath);
7474
if (binaryPackagePath === tempBinaryPackagePath) {
7575
// We've hit the disk root
@@ -82,7 +82,7 @@ export abstract class BaseCmdTask<TTaskConfig extends IBaseCmdTaskConfig> extend
8282

8383
if (this.taskConfig.overridePackagePath) {
8484
// The package version is being overridden
85-
if (!fsx.existsSync(this.taskConfig.overridePackagePath)) {
85+
if (!FileSystem.exists(this.taskConfig.overridePackagePath)) {
8686
completeCallback(
8787
`The specified ${this._packageName} path (${this.taskConfig.overridePackagePath}) does not ` +
8888
'exist'
@@ -98,7 +98,7 @@ export abstract class BaseCmdTask<TTaskConfig extends IBaseCmdTaskConfig> extend
9898
this.log(`${this._packageName} version: ${packageJson.version}`);
9999

100100
const binaryPath: string = path.resolve(binaryPackagePath, this._packageBinPath);
101-
if (!fsx.existsSync(binaryPath)) {
101+
if (!FileSystem.exists(binaryPath)) {
102102
completeCallback(
103103
`The binary is missing. This indicates that ${this._packageName} is not ` +
104104
'installed correctly.'

‎core-build/gulp-core-build-typescript/src/miniTasks/TscCmdTask.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// See LICENSE in the project root for license information.
33

44
import * as path from 'path';
5-
import { JsonFile } from '@microsoft/node-core-library';
6-
import * as fsx from 'fs-extra';
5+
import {
6+
JsonFile,
7+
FileSystem
8+
} from '@microsoft/node-core-library';
79
import * as glob from 'glob';
810

911
import {
@@ -70,12 +72,11 @@ export class TscCmdTask extends BaseCmdTask<ITscCmdTaskConfig> {
7072
reject(error);
7173
} else {
7274
for (const matchPath of matchPaths) {
73-
const fileContents: Buffer = fsx.readFileSync(matchPath);
75+
const fileContents: string = FileSystem.readFile(matchPath);
7476
const relativePath: string = path.relative(srcPath, matchPath);
7577
for (const resolvedLibFolder of resolvedLibFolders) {
7678
const destPath: string = path.join(resolvedLibFolder, relativePath);
77-
fsx.ensureDirSync(path.dirname(destPath));
78-
fsx.writeFileSync(destPath, fileContents);
79+
FileSystem.writeFile(destPath, fileContents, { ensureFolderExists: true });
7980
}
8081
}
8182

0 commit comments

Comments
 (0)