Skip to content

Commit

Permalink
Merge branch 'main' into readme@55651a3
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsute authored Jan 1, 2025
2 parents e148dfc + 7c663dd commit 06d9b98
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"image": "node:20",
"image": "node:22",
"postAttachCommand": "npm i",
"shutdownAction": "stopContainer"
}
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## 3.1.0

### New Features

* Add env var `${vscode:user}` for `Code/User` directory [#436](https://github.com/KatsuteDev/Background/pull/436) ([@Katsute](https://github.com/Katsute))

On desktop this is the `Code/User` directory.

On portable this is the `data/user-data/User` directory.

### Dependencies

* Bump esbuild from 0.23.1 to 0.24.0 [#415](https://github.com/KatsuteDev/Background/pull/415) ([@dependabot](https://github.com/dependabot))
* Bump @types/node from 22.5.0 to 22.7.4 [#417](https://github.com/KatsuteDev/Background/pull/417) ([@dependabot](https://github.com/dependabot))
* Bump @vscode/vsce from 3.1.0 to 3.1.1 [#418](https://github.com/KatsuteDev/Background/pull/418) ([@dependabot](https://github.com/dependabot))
* Bump @types/vscode from 1.93.0 to 1.94.0 [#419](https://github.com/KatsuteDev/Background/pull/419) ([@dependabot](https://github.com/dependabot))
* Bump @vscode/vsce from 3.1.1 to 3.2.0 [#422](https://github.com/KatsuteDev/Background/pull/422) ([@dependabot](https://github.com/dependabot))
* Bump @types/node from 22.7.4 to 22.8.1 [#425](https://github.com/KatsuteDev/Background/pull/425) ([@dependabot](https://github.com/dependabot))
* Bump @vscode/vsce from 3.2.0 to 3.2.1 [#424](https://github.com/KatsuteDev/Background/pull/424) ([@dependabot](https://github.com/dependabot))
* Bump @types/vscode from 1.94.0 to 1.95.0 [#427](https://github.com/KatsuteDev/Background/pull/427) ([@dependabot](https://github.com/dependabot))
* Bump @types/node from 22.8.1 to 22.9.0 [#428](https://github.com/KatsuteDev/Background/pull/428) ([@dependabot](https://github.com/dependabot))
* Bump typescript from 5.6.3 to 5.7.2 [#430](https://github.com/KatsuteDev/Background/pull/430) ([@dependabot](https://github.com/dependabot))
* Bump @types/node from 22.9.0 to 22.10.1 [#431](https://github.com/KatsuteDev/Background/pull/431) ([@dependabot](https://github.com/dependabot))
* Bump @types/vscode from 1.95.0 to 1.96.0 [#434](https://github.com/KatsuteDev/Background/pull/434) ([@dependabot](https://github.com/dependabot))
* Bump esbuild from 0.24.0 to 0.24.2 [#437](https://github.com/KatsuteDev/Background/pull/437) ([@dependabot](https://github.com/dependabot))

**Full Changelog**: [`3.0.2...3.1.0`](https://github.com/KatsuteDev/Background/compare/3.0.2...3.1.0)

## 3.0.2

### Fixes
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ Use the <kbd>Background: Configuration</kbd> command or press the **Background**

## Environment Variables

If the path is not working, add an additional `/` after the variable.

|Variable|Description|
|:--|:--|
|`${vscode:workspace}`|Current VSCode project folder|
|`${vscode:user}`|VSCode user directory, either `Code/User` or `data/user-data/User`|
|`${user:home}`|Current user's home directory|
|`${...}`|System environment variable|

Expand Down
58 changes: 42 additions & 16 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 @@ -364,7 +364,7 @@
},
"homepage": "https://github.com/KatsuteDev/Background#readme",
"devDependencies": {
"@types/node": "22.10.1",
"@types/node": "22.10.2",
"@types/tmp": "0.2.6",
"@types/vscode": "1.96.0",
"@vscode/l10n-dev": "0.0.35",
Expand Down
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { install, uninstall } from "./extension/writer";
import { optionMenu } from "./menu/menu";
import { configuration, get, update } from "./extension/config";
import { env } from "vscode";
import { setUserDir } from "./extension/env";

//

Expand Down Expand Up @@ -58,6 +59,8 @@ export const activate: (context: ExtensionContext) => any = (context: ExtensionC

const dir = env.appRoot;

setUserDir(join(context.globalStorageUri.fsPath, "../../../User")); // for env var

// internal files
if(dir){
// %appdata%/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js
Expand Down
14 changes: 12 additions & 2 deletions src/extension/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ import { escape as esc } from "../lib/glob";

const home: string = homedir();

export const setUserDir: (path: string) => void = (path: string) => {
if(!user){ // disallow reassignment
user = path.replace(/\/$/, ''); // remove last slash
}
};

let user: string;

export const resolve: (str: string) => string = (str: string) =>
str.replace(/\${(.*?)}/g, (_, envvar) => {
if(envvar == "vscode:workspace" && workspace.workspaceFolders && workspace.workspaceFolders.length > 0 && workspace.workspaceFolders[0].uri){
if(envvar === "vscode:workspace" && workspace.workspaceFolders && workspace.workspaceFolders.length > 0 && workspace.workspaceFolders[0].uri){
return esc(workspace.workspaceFolders[0].uri.fsPath.toString());
}else if(envvar == "user:home"){
}else if(envvar === "vscode:user" && user){
return esc(user);
}else if(envvar === "user:home"){
return esc(home);
}else if(envvar in process.env){
return esc(process.env[envvar] || '');
Expand Down
Loading

0 comments on commit 06d9b98

Please sign in to comment.