Skip to content

Commit c67be21

Browse files
committed
Code cleanup
1 parent e4b6621 commit c67be21

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

src/commands/compile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ export async function importFolder(uri: vscode.Uri, noCompile = false): Promise<
318318
if (fs.lstatSync(uripath).isFile()) {
319319
return importFiles([uripath], noCompile);
320320
}
321-
var globpattern = "*.{cls,inc,int,mac}";
321+
let globpattern = "*.{cls,inc,int,mac}";
322322
const workspace = currentWorkspaceFolder();
323323
const workspacePath = workspaceFolderUri(workspace).fsPath;
324324
const { folder } = config("export", workspace);
325-
const folderPathNoWorkspaceArr = uripath.replace(workspacePath+path.sep,'').split(path.sep);
325+
const folderPathNoWorkspaceArr = uripath.replace(workspacePath + path.sep, "").split(path.sep);
326326
if (folderPathNoWorkspaceArr[0] === folder) {
327327
// This folder is in the export tree, so import all files
328328
// We need to include eveything becuase CSP applications can

src/commands/export.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export const getFileName = (
5050
const nameArr: string[] = name.split("/");
5151
const cat = addCategory ? getCategory(name, addCategory) : null;
5252
return [folder, cat, ...nameArr].filter(notNull).join(path.sep);
53-
}
54-
else {
53+
} else {
5554
// This is a class, routine or include file
5655
if (map) {
5756
for (const pattern of Object.keys(map)) {
@@ -134,23 +133,18 @@ export async function exportFile(
134133
if (Buffer.isBuffer(content)) {
135134
// This is a binary file
136135
let isSkipped = "";
137-
138136
if (dontExportIfNoChanges && fs.existsSync(fileName)) {
139137
const existingContent = fs.readFileSync(fileName);
140138
if (content.equals(existingContent)) {
141139
fs.writeFileSync(fileName, content);
142-
}
143-
else {
140+
} else {
144141
isSkipped = " => skipped - no changes.";
145142
}
146-
}
147-
else {
143+
} else {
148144
fs.writeFileSync(fileName, content);
149145
}
150-
151146
log(`Success ${isSkipped}`);
152-
}
153-
else {
147+
} else {
154148
// This is a text file
155149
let joinedContent = content.join("\n");
156150
let isSkipped = "";

src/extension.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import {
7575
notNull,
7676
currentFile,
7777
InputBoxManager,
78-
isImportableLocalFile
78+
isImportableLocalFile,
7979
} from "./utils";
8080
import { ObjectScriptDiagnosticProvider } from "./providers/ObjectScriptDiagnosticProvider";
8181
import { DocumentRangeFormattingEditProvider } from "./providers/DocumentRangeFormattingEditProvider";
@@ -522,10 +522,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
522522
if (documentBeingProcessed !== file) {
523523
return importAndCompile(false, file);
524524
}
525-
}
526-
else if (file.uri.scheme === "file") {
525+
} else if (file.uri.scheme === "file") {
527526
if (isImportableLocalFile(file)) {
528-
// This local file is in the exported file tree, so it's a non-InterSystems file that's
527+
// This local file is in the exported file tree, so it's a non-InterSystems file that's
529528
// part of a CSP application, so import it on save
530529
return importFileOrFolder(file.uri, true);
531530
}

src/utils/index.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ export interface ConnectionTarget {
6262
* @param workspace The workspace the file is in.
6363
*/
6464
function getServerDocName(localPath: string, workspace: string): string {
65-
var result = localPath;
65+
let result = localPath;
6666
const workspacePath = workspaceFolderUri(workspace).fsPath;
67-
result = result.replace(workspacePath+path.sep,'');
67+
result = result.replace(workspacePath + path.sep, "");
6868
const { folder, addCategory } = config("export", workspace);
69-
result = result.replace(folder+path.sep,'');
69+
result = result.replace(folder + path.sep, "");
7070
const cat = addCategory ? getCategory(localPath, addCategory) : null;
7171
if (cat !== null) {
72-
result = result.replace(cat+path.sep,'');
72+
result = result.replace(cat + path.sep, "");
7373
}
74-
return result.replace(path.sep,"/");
74+
return result.replace(path.sep, "/");
7575
}
7676

7777
/**
@@ -80,11 +80,11 @@ function getServerDocName(localPath: string, workspace: string): string {
8080
* @param file The file to check.
8181
*/
8282
export function isImportableLocalFile(file: vscode.TextDocument): boolean {
83-
var result = false;
83+
let result = false;
8484
const workspace = currentWorkspaceFolder(file);
8585
const workspacePath = workspaceFolderUri(workspace).fsPath;
8686
const { folder, addCategory } = config("export", workspace);
87-
const filePathNoWorkspaceArr = file.fileName.replace(workspacePath+path.sep,'').split(path.sep);
87+
const filePathNoWorkspaceArr = file.fileName.replace(workspacePath + path.sep, "").split(path.sep);
8888
const cat = addCategory ? getCategory(file.fileName, addCategory) : null;
8989
if (filePathNoWorkspaceArr[0] === folder) {
9090
if (cat === null || (cat !== null && filePathNoWorkspaceArr[1] === cat)) {
@@ -142,9 +142,8 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
142142
}
143143
} else {
144144
if (document.uri.scheme === "file") {
145-
name = getServerDocName(fileName,currentWorkspaceFolder(document));
146-
}
147-
else {
145+
name = getServerDocName(fileName, currentWorkspaceFolder(document));
146+
} else {
148147
name = fileName;
149148
}
150149
// Need to strip leading / for custom Studio documents which should not be treated as files.

0 commit comments

Comments
 (0)