8000 Update `savePackageFiles` to only work on modified files by damolina-stripe · Pull Request #7240 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update savePackageFiles to only work on modified files #7240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions vscode_extension/src/commands/savePackageFiles.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { workspace } from "vscode";
import { basename } from "path";
import { SorbetExtensionContext } from "../sorbetExtensionContext";

/**
* Save all open __package.rb files
* Save all __package.rb files with changes.
*
* @param context Sorbet extension context.
* @return true if all the files were successfully saved
* @return `true` if all the files were successfully saved.
*/
export async function savePackageFiles(
context: SorbetExtensionContext,
): Promise<boolean> {
context.log.trace("savePackageFiles");
const packageDocuments = workspace.textDocuments.filter(
(document) =>
document.isDirty && basename(document.fileName) === "__package.rb",
);
if (!packageDocuments.length) {
context.log.trace("savePackageFiles: nothing to save");
return true;
}

const allSaved = await Promise.all(
workspace.textDocuments.map(async (document) => {
packageDocuments.map((document) => {
context.log.trace(`savePackageFiles: saving ${document.fileName}`);
if (document.fileName.endsWith("/__package.rb")) {
return document.save();
}

return true;
return document.save();
}),
);

Expand Down
0