Skip to content

Commit 138d91d

Browse files
author
Nick Pape
committed
Fix issues
1 parent 77fe04f commit 138d91d

File tree

9 files changed

+45
-15
lines changed

9 files changed

+45
-15
lines changed

apps/rush-lib/src/api/RushConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export class RushConfiguration {
297297
for (const filename of FileSystem.readFolder(commonRushConfigFolder)) {
298298

299299
// Ignore things that aren't actual files
300-
const stat: fs.Stats = FileSystem.getStatistics(filename);
300+
const stat: fs.Stats = FileSystem.getStatistics(path.join(commonRushConfigFolder, filename));
301301
if (!stat.isFile() && !stat.isSymbolicLink()) {
302302
continue;
303303
}

common/reviews/api/node-core-library.api.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// @public
2+
class File {
3+
// (undocumented)
4+
close(): void;
5+
// (undocumented)
6+
static open(path: string, mode: string): File;
7+
// (undocumented)
8+
write(text: string): void;
9+
}
10+
111
// @public
212
enum FileConstants {
313
PackageJson = "package.json"
@@ -12,6 +22,8 @@ class FileDiffTest {
1222

1323
// @public
1424
class FileSystem {
25+
// (undocumented)
26+
static changeMode(path: string, mode: number): void;
1527
// (undocumented)
1628
static copyFile(sourcePath: string, destinationPath: string): void;
1729
// (undocumented)
@@ -22,7 +34,6 @@ class FileSystem {
2234
static createSymbolicLinkToFile(linkSource: string, linkTarget: string): void;
2335
// (undocumented)
2436
static createSymbolicLinkToFolder(linkSource: string, linkTarget: string): void;
25-
// WARNING: The type "IDeleteFileOptions" needs to be exported by the package (e.g. added to index.ts)
2637
// (undocumented)
2738
static deleteFile(filePath: string, options?: IDeleteFileOptions): void;
2839
// (undocumented)
@@ -35,7 +46,6 @@ class FileSystem {
3546
static followLink(linkPath: string): string;
3647
// (undocumented)
3748
static getStatistics(path: string): fs.Stats;
38-
// WARNING: The type "IMoveOptions" needs to be exported by the package (e.g. added to index.ts)
3949
// (undocumented)
4050
static move(sourcePath: string, destinationPath: string, options?: IMoveOptions): void;
4151
// (undocumented)
@@ -45,6 +55,8 @@ class FileSystem {
4555
// (undocumented)
4656
static readFolder(folderPath: string, options?: IReadFolderOptions): Array<string>;
4757
// (undocumented)
58+
static updateTimes(path: string, accessedTime: number, modifiedTime: number): void;
59+
// (undocumented)
4860
static writeFile(filePath: string, contents: string, options?: IWriteFileOptions): void;
4961
}
5062

@@ -54,6 +66,12 @@ enum FolderConstants {
5466
NodeModules = "node_modules"
5567
}
5668

69+
// @public
70+
interface IDeleteFileOptions {
71+
// (undocumented)
72+
throwIfNotExists?: boolean;
73+
}
74+
5775
// @public
5876
interface IJsonFileSaveOptions extends IJsonFileStringifyOptions {
5977
onlyIfChanged?: boolean;
@@ -79,6 +97,12 @@ interface IJsonSchemaValidateOptions {
7997
customErrorHeader?: string;
8098
}
8199

100+
// @public
101+
interface IMoveOptions {
102+
// (undocumented)
103+
overwrite?: boolean;
104+
}
105+
82106
// @public
83107
interface IPackageJson {
84108
bin?: string;
@@ -143,7 +167,7 @@ interface IReadFileOptions {
143167
// (undocumented)
144168
convertLineEndings?: NewlineConversion;
145169
// (undocumented)
146-
encoding?: string | undefined;
170+
encoding?: Encoding;
147171
}
148172

149173
// @public
@@ -156,7 +180,7 @@ interface IWriteFileOptions {
156180
// (undocumented)
157181
convertLineEndings?: NewlineConversion;
158182
// (undocumented)
159-
encoding?: string | undefined;
183+
encoding?: Encoding;
160184
// (undocumented)
161185
ensureFolder?: boolean;
162186
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@microsoft/api-extractor';
1313
import { TypeScriptConfiguration } from './TypeScriptConfiguration';
1414
import gulpTypeScript = require('gulp-typescript');
15-
import { FileSystem } from '../../../libraries/node-core-library/dist/index-internal';
15+
import { FileSystem } from '@microsoft/node-core-library';
1616

1717
/** @public */
1818
export interface IApiExtractorTaskConfig {

libraries/node-core-library/src/FileDiffTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55

66
import { PackageJsonLookup } from './PackageJsonLookup';
77
import { Text } from './Text';
8-
import { FileSystem } from '../lib/FileSystem';
8+
import { FileSystem } from './FileSystem';
99

1010
/**
1111
* Implements a unit testing strategy that generates output files, and then

libraries/node-core-library/src/FileSystem.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,17 @@ export class FileSystem {
196196
}
197197
}
198198

199+
/**
200+
* API for interacting with file handles
201+
* @public
202+
*/
199203
export class File {
200204
private _fileDescriptor: number | undefined;
201205

202206
public static open(path: string, mode: string): File {
203207
return new File(fsx.openSync(path, mode));
204208
}
205209

206-
private constructor(fileDescriptor: number) {
207-
this._fileDescriptor = fileDescriptor;
208-
}
209-
210210
public write(text: string): void {
211211
if (!this._fileDescriptor) {
212212
throw new Error(`Cannot write to file, file descriptor has already been released.`);
@@ -224,4 +224,8 @@ export class File {
224224
this._fileDescriptor = undefined;
225225
fsx.closeSync(fd);
226226
}
227+
228+
private constructor(fileDescriptor: number) {
229+
this._fileDescriptor = fileDescriptor;
230+
}
227231
}

libraries/node-core-library/src/JsonSchema.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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 os from 'os';
65
import * as path from 'path';
76
import Validator = require('z-schema');

libraries/node-core-library/src/PackageJsonLookup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as path from 'path';
77
import { JsonFile } from './JsonFile';
88
import { IPackageJson } from './IPackageJson';
99
import { FileConstants } from './Constants';
10-
import { FileSystem } from '../dist/index-internal';
10+
import { FileSystem } from './FileSystem';
1111

1212
/**
1313
* Constructor parameters for {@link PackageJsonLookup}

libraries/node-core-library/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ export { Path } from './Path';
4848
export { Text } from './Text';
4949
export {
5050
FileSystem,
51+
File,
5152
IReadFolderOptions,
5253
IWriteFileOptions,
5354
IReadFileOptions,
55+
IMoveOptions,
56+
IDeleteFileOptions,
5457
NewlineConversion
5558
} from './FileSystem';

stack/rush-stack/src/logic/BasicTasks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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 child_process from 'child_process';
76

87
import { BuildContext } from './BuildContext';
8+
import { FileSystem } from '@microsoft/node-core-library';
99

1010
export class BasicTasks {
1111
/**
@@ -21,7 +21,7 @@ export class BasicTasks {
2121
for (const folderToClean of foldersToClean) {
2222
const fullPath: string = path.join(buildContext.projectFolder, folderToClean);
2323
console.log(`[clean]: Cleaning "${fullPath}"`);
24-
fsx.emptyDirSync(fullPath);
24+
FileSystem.emptyFolder(fullPath);
2525
}
2626
}
2727

0 commit comments

Comments
 (0)