mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
Dont fail on "create" event when watching package json files (#57971)
This commit is contained in:
parent
54504fc9b3
commit
f3f70df94e
@ -4682,7 +4682,6 @@ export class ProjectService {
|
||||
(fileName, eventKind) => {
|
||||
switch (eventKind) {
|
||||
case FileWatcherEventKind.Created:
|
||||
return Debug.fail();
|
||||
case FileWatcherEventKind.Changed:
|
||||
this.packageJsonCache.addOrUpdate(fileName, path);
|
||||
this.onPackageJsonChange(result);
|
||||
|
||||
@ -290,6 +290,8 @@ export interface WatchInvokeOptions {
|
||||
invokeFileDeleteCreateAsPartInsteadOfChange: boolean;
|
||||
/** Dont invoke delete watches */
|
||||
ignoreDelete: boolean;
|
||||
/** ignore all watches */
|
||||
ignoreWatches?: boolean;
|
||||
/** Skip inode check on file or folder create*/
|
||||
skipInodeCheckOnCreate: boolean;
|
||||
/** When invoking rename event on fs watch, send event with file name suffixed with tilde */
|
||||
@ -501,6 +503,7 @@ export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost,
|
||||
else {
|
||||
currentEntry.content = content;
|
||||
currentEntry.modifiedTime = this.now();
|
||||
if (options?.ignoreWatches) return;
|
||||
if (options && options.invokeDirectoryWatcherInsteadOfFileChanged) {
|
||||
const directoryFullPath = getDirectoryPath(currentEntry.fullPath);
|
||||
this.fs.get(getDirectoryPath(currentEntry.path))!.modifiedTime = this.now();
|
||||
@ -628,7 +631,7 @@ export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost,
|
||||
this.fs.set(fileOrDirectory.path, fileOrDirectory);
|
||||
this.setInode(fileOrDirectory.path);
|
||||
|
||||
if (ignoreWatch) {
|
||||
if (ignoreWatch || options?.ignoreWatches) {
|
||||
return;
|
||||
}
|
||||
const inodeWatching = this.inodeWatching;
|
||||
@ -651,9 +654,9 @@ export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost,
|
||||
if (isFsFolder(fileOrDirectory)) {
|
||||
Debug.assert(fileOrDirectory.entries.length === 0 || isRenaming);
|
||||
}
|
||||
if (!options?.ignoreDelete) this.invokeFileAndFsWatches(fileOrDirectory.fullPath, FileWatcherEventKind.Deleted, /*modifiedTime*/ undefined, options?.useTildeAsSuffixInRenameEventFileName);
|
||||
if (!options?.ignoreDelete && !options?.ignoreWatches) this.invokeFileAndFsWatches(fileOrDirectory.fullPath, FileWatcherEventKind.Deleted, /*modifiedTime*/ undefined, options?.useTildeAsSuffixInRenameEventFileName);
|
||||
this.inodes?.delete(fileOrDirectory.path);
|
||||
if (!options?.ignoreDelete) this.invokeFileAndFsWatches(baseFolder.fullPath, FileWatcherEventKind.Changed, baseFolder.modifiedTime, options?.useTildeAsSuffixInRenameEventFileName);
|
||||
if (!options?.ignoreDelete && !options?.ignoreWatches) this.invokeFileAndFsWatches(baseFolder.fullPath, FileWatcherEventKind.Changed, baseFolder.modifiedTime, options?.useTildeAsSuffixInRenameEventFileName);
|
||||
}
|
||||
|
||||
deleteFile(filePath: string) {
|
||||
|
||||
@ -76,14 +76,16 @@ describe("unittests:: tsserver:: moduleResolution", () => {
|
||||
const { host, session, packageFile, verifyErr } = setup(jsonToReadableText({ name: "app", version: "1.0.0" }));
|
||||
|
||||
session.logger.info("Modify package json file to add type module");
|
||||
host.writeFile(
|
||||
host.modifyFile(
|
||||
packageFile.path,
|
||||
jsonToReadableText({
|
||||
name: "app",
|
||||
version: "1.0.0",
|
||||
type: "module",
|
||||
}),
|
||||
{ ignoreWatches: true },
|
||||
);
|
||||
host.invokeFsWatches(packageFile.path, "rename", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined); // Create event instead of change
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookup updates
|
||||
host.runQueuedTimeoutCallbacks(); // Actual update
|
||||
verifyErr();
|
||||
|
||||
@ -244,11 +244,11 @@ ScriptInfos::
|
||||
/user/username/projects/myproject/src/tsconfig.json
|
||||
|
||||
Info seq [hh:mm:ss:mss] Modify package json file to add type module
|
||||
Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution
|
||||
Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution
|
||||
Info seq [hh:mm:ss:mss] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation
|
||||
Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution
|
||||
Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file
|
||||
Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file
|
||||
Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution
|
||||
Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file
|
||||
Info seq [hh:mm:ss:mss] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file
|
||||
Before running Timeout callback:: count: 1
|
||||
1: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation
|
||||
//// [/user/username/projects/myproject/package.json]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user