Skip to content

Commit

Permalink
Fix some whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed May 9, 2024
1 parent 0fdd78e commit b632252
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions apps/vscode/src/providers/preview/preview-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ export function isQuartoShinyKnitrDoc(

export async function isRPackage() {
const descriptionLines = await parseRPackageDescription();
const packageLines = descriptionLines.filter(line => line.startsWith('Package:'));
const typeLines = descriptionLines.filter(line => line.startsWith('Type:'));
const typeIsPackage = (typeLines.length > 0
? typeLines[0].toLowerCase().includes('package')
: false);
const typeIsPackageOrMissing = typeLines.length === 0 || typeIsPackage;
return packageLines.length > 0 && typeIsPackageOrMissing;
const packageLines = descriptionLines.filter(line => line.startsWith('Package:'));
const typeLines = descriptionLines.filter(line => line.startsWith('Type:'));
const typeIsPackage = (typeLines.length > 0
? typeLines[0].toLowerCase().includes('package')
: false);
const typeIsPackageOrMissing = typeLines.length === 0 || typeIsPackage;
return packageLines.length > 0 && typeIsPackageOrMissing;
}

async function parseRPackageDescription(): Promise<string[]> {
if (vscode.workspace.workspaceFolders !== undefined) {
const folderUri = vscode.workspace.workspaceFolders[0].uri;
const fileUri = vscode.Uri.joinPath(folderUri, 'DESCRIPTION');
try {
const bytes = await vscode.workspace.fs.readFile(fileUri);
const descriptionText = Buffer.from(bytes).toString('utf8');
const descriptionLines = descriptionText.split(/(\r?\n)/);
return descriptionLines;
} catch { }
}
return [''];
if (vscode.workspace.workspaceFolders !== undefined) {
const folderUri = vscode.workspace.workspaceFolders[0].uri;
const fileUri = vscode.Uri.joinPath(folderUri, 'DESCRIPTION');
try {
const bytes = await vscode.workspace.fs.readFile(fileUri);
const descriptionText = Buffer.from(bytes).toString('utf8');
const descriptionLines = descriptionText.split(/(\r?\n)/);
return descriptionLines;
} catch { }
}
return [''];
}

export async function renderOnSave(engine: MarkdownEngine, document: TextDocument) {
Expand Down

0 comments on commit b632252

Please sign in to comment.