Skip to content

Commit

Permalink
Create node.js.yml (#52)
Browse files Browse the repository at this point in the history
* Add node.js.yml

* Add new line at end of file

* Fix warnings

* Fix warnings

* Fix errors

* Fix warnings

* Fix errors

* Fix errors

* Bump actions/checkoutto v4. Quote node-version values

* Refactor with reference from https://code.visualstudio.com/api/working-with-extensions/continuous-integration

* Provide names

* Copy from https://code.visualstudio.com/api/working-with-extensions/continuous-integration

* Fix unit tests

* Remove macos-latest

* Upgrade vscode/test-electron to ^2.3.8

* Upgrade @vscode/test-electron

* Add macos-latest

* Fix os matrix
  • Loading branch information
KAHLYM authored Jan 13, 2024
1 parent 3145ff7 commit 3d168ec
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 104 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node.js

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- run: npm install
- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
"@types/vscode": "^1.82.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@vscode/test-electron": "^2.3.4",
"@vscode/test-electron": "^2.3.8",
"eslint": "^8.47.0",
"glob": "^10.3.3",
"mocha": "^10.2.0",
Expand Down
12 changes: 6 additions & 6 deletions src/entry-state-decorator-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ export class EntryStateDecorationProvider implements vscode.FileDecorationProvid
}

async provideFileDecoration(uri: vscode.Uri) {
if (uri.scheme != "file-comparison") {
if (uri.scheme !== "file-comparison") {
return null;
}

switch (await this.getStatus(uri)) {
case Status.Addition: {
case Status.addition: {
let decoration: vscode.FileDecoration = new vscode.FileDecoration("A", "addition", new vscode.ThemeColor("folderComparison.color.added"));
decoration.propagate = true;
return decoration;
}
case Status.Deletion: {
case Status.deletion: {
let decoration: vscode.FileDecoration = new vscode.FileDecoration("D", "deletion", new vscode.ThemeColor("folderComparison.color.deleted"));
decoration.propagate = true;
return decoration;
}
case Status.Modification: {
case Status.modification: {
let decoration: vscode.FileDecoration = new vscode.FileDecoration("M", "modification", new vscode.ThemeColor("folderComparison.color.modified"));
decoration.propagate = true;
return decoration;
}
case Status.Rename: {
case Status.rename: {
let decoration: vscode.FileDecoration = new vscode.FileDecoration("R", "rename", new vscode.ThemeColor("folderComparison.color.renamed"));
decoration.propagate = true;
return decoration;
}
case Status.Null: {
case Status.null: {
let decoration: vscode.FileDecoration = new vscode.FileDecoration("", "", new vscode.ThemeColor("folderComparison.color.ignored"));
decoration.propagate = true;
return decoration;
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ export function activate(context: vscode.ExtensionContext) {
clearInterval(refreshInterval);
refreshInterval = setRefreshInterval();
} else if (event.affectsConfiguration("folderComparison.logLevel")) {
const logLevel = vscode.workspace.getConfiguration('folderComparison').get<string>('logLevel') ?? logger.DefaultLevel;
const logLevel = vscode.workspace.getConfiguration('folderComparison').get<string>('logLevel') ?? logger.defaultLevel;
logger.info(`User configured log level to be ${logLevel}`);
logger.setLogLevel(logLevel);
} else if (event.affectsConfiguration("folderComparison.showUnchanged")) {
fileSystemProvider.refresh();
}
})
});
}

async function warnAboutMissingGit(): Promise<void> {
Expand Down
58 changes: 29 additions & 29 deletions src/file-system-provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import * as utilities from './utilities';
import { Command, Event, EventEmitter, TreeItem, Uri, FileType, TreeDataProvider, FileStat, TreeItemCollapsibleState, workspace } from 'vscode'
import { Command, Event, EventEmitter, TreeItem, Uri, FileType, TreeDataProvider, FileStat, TreeItemCollapsibleState, workspace } from 'vscode';
import { diff, Status, statusToString } from './git';
import { FileSystemTrie, FileSystemTrieNode } from './trie';

Expand Down Expand Up @@ -61,7 +61,7 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {

private isValid(): boolean {
// TODO Fix Uri implementation in regards to consistency
return this.left.path != Uri.parse("").path && this.right.path != Uri.parse("").path;
return this.left.path !== Uri.parse("").path && this.right.path !== Uri.parse("").path;
}

private async _stat(path: string): Promise<FileStat> {
Expand Down Expand Up @@ -96,11 +96,11 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {
path = toUnix(path);

if (right) {
path = path.replace(toUnix(this.right.fsPath), "")
path = path.replace(toUnix(this.right.fsPath), "");
}

if (left) {
path = path.replace(toUnix(this.left.fsPath), "")
path = path.replace(toUnix(this.left.fsPath), "");
}

return path.substring(1);
Expand All @@ -122,7 +122,7 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {
Uri.parse(""),
name,
type,
Status.Null);
Status.null);
}
});
} else { // getChildren called against subdirectory
Expand All @@ -138,7 +138,7 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {
Uri.parse(""),
toUnix(namepath),
type,
Status.Null);
Status.null);
}
});
}
Expand All @@ -153,25 +153,25 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {
const rightSubpath: string = this.removePrefix(item.content.right, false, true);

switch (item.content.status) {
case Status.Addition:
case Status.addition:
childCache[rightSubpath] = new FileTreeItem(
item.content.left,
item.content.right,
directory == "" ? item.key : directory + path.posix.sep + item.key,
directory === "" ? item.key : directory + path.posix.sep + item.key,
FileType.File,
item.content.status
);
break;
case Status.Deletion:
childCache[leftSubpath].status = Status.Deletion;
case Status.deletion:
childCache[leftSubpath].status = Status.deletion;
break;
case Status.Modification:
childCache[leftSubpath].status = Status.Modification;
case Status.modification:
childCache[leftSubpath].status = Status.modification;
break;
case Status.Rename:
if (childCache[leftSubpath] != undefined) {
case Status.rename:
if (childCache[leftSubpath] !== undefined) {
delete childCache[leftSubpath];
} else if (childCache[rightSubpath] != undefined) {
} else if (childCache[rightSubpath] !== undefined) {
childCache[rightSubpath] = new FileTreeItem(
item.content.left,
item.content.right,
Expand All @@ -181,12 +181,12 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {
);
}
break;
case Status.Null:
if (childCache[item.key] == undefined) {
case Status.null:
if (childCache[item.key] === undefined) {
childCache[item.key] = new FileTreeItem(
item.content.left,
item.content.right,
directory == "" ? item.key : directory + path.posix.sep + item.key,
directory === "" ? item.key : directory + path.posix.sep + item.key,
FileType.Directory,
item.content.status
);
Expand Down Expand Up @@ -233,28 +233,28 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {
}

private getRightUri(element: FileTreeItem): Uri {
return Uri.file(this.right.path.substring(1) + path.posix.sep + element?.subpath)
return Uri.file(this.right.path.substring(1) + path.posix.sep + element?.subpath);
}

private getCommand(element: FileTreeItem): Command | void {
switch (element.status) {
case Status.Addition:
case Status.addition:
return {
command: 'vscode.open',
title: 'Open',
arguments: [
this.getRightUri(element)
]
}
case Status.Deletion:
};
case Status.deletion:
return {
command: 'vscode.open',
title: 'Open',
arguments: [
this.getLeftUri(element)
]
}
case Status.Modification:
};
case Status.modification:
return {
command: 'vscode.diff',
title: 'Open',
Expand All @@ -263,23 +263,23 @@ export class FileSystemProvider implements TreeDataProvider<FileTreeItem> {
this.getRightUri(element),
element.subpath + " (Modified)"
]
}
case Status.Rename:
};
case Status.rename:
return {
command: 'vscode.open',
title: 'Open',
arguments: [
this.getRightUri(element),
]
}
case Status.Null:
};
case Status.null:
return {
command: 'vscode.open',
title: 'Open',
arguments: [
this.getLeftUri(element),
]
}
};
}
}
}
Loading

0 comments on commit 3d168ec

Please sign in to comment.