Skip to content

Commit 632b303

Browse files
Merge pull request #21 from Luke-zhang-04/dev
2 parents 15151ba + c9cbaf6 commit 632b303

File tree

13 files changed

+1906
-19
lines changed

13 files changed

+1906
-19
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ jobs:
2525

2626
- name: check with prettier
2727
run: yarn prettier . --check
28+
29+
- name: test
30+
run: yarn test

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.4.1] - 2021-12-17
9+
10+
### Added
11+
12+
- feat: accomidate for legacy `processing.path` conig option
13+
14+
### Fixed
15+
16+
- fix: escape spaces in executable path
17+
818
## [2.4.0] - 2021-07-10
919

1020
### Added

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Note on Processing 4: I'm not sure how this extension will handle Processing 4.
2424
- [Snippets](#snippets)
2525
- [Documentation on Hover](#documentation-on-hover)
2626
- [Commands](#commands)
27+
- [Using task files](#using-task-files)
2728
- [Processing Python](#processing-python)
2829
- [Credits](#credits)
2930

@@ -95,6 +96,12 @@ Installing this extension will add the following commands to your command pallet
9596
- Use the pallet command "Processing: Search Processing Website" to quickly search whatever you want on the processing website.
9697
- By default uses Google for search. Can change to DuckDuckGo if preferred using the `processing.search` setting.
9798

99+
## Using Task Files
100+
101+
The [original extension](https://github.com/TobiahZ/processing-vscode) made use of a [tasks.json](https://github.com/TobiahZ/processing-vscode/blob/b98d44b095b303f7f66017c632b17e47fa00dfcd/ProcessingTasks.json) file to run processing projects. This has been replaced with the run command and run button (processing.Run). You can bind this command to a keybinding.
102+
103+
Alternatively, if you prefer the `tasks.json` file, you can continue to use it, but the `command` field should be changed to `"${config:processing.path}"`.
104+
98105
## Processing Python
99106

100107
This extension attempts to make Processing with Python easier to use. Follow these steps:

__tests__/index.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {escapeExecutablePath} from "../src/utils/escapePath"
2+
3+
describe("test path escape", () => {
4+
it("should escape Windows path with space", () => {
5+
const originalPath = "C:\\Program Files\\processing\\processing-java"
6+
7+
expect(escapeExecutablePath(originalPath)).toBe(
8+
"C:\\Program` Files\\processing\\processing-java",
9+
)
10+
})
11+
12+
it("should escape Unix path with space", () => {
13+
const originalPath = "/usr/bin/something else/processing-java"
14+
15+
expect(escapeExecutablePath(originalPath)).toBe(
16+
"/usr/bin/something\\ else/processing-java",
17+
)
18+
})
19+
20+
it("should leave Windows path without spaces as is", () => {
21+
const originalPath = ".\\processing\\processing-java"
22+
23+
expect(escapeExecutablePath(originalPath)).toBe(".\\processing\\processing-java")
24+
})
25+
26+
it("should leave Unix path without spaces as is", () => {
27+
const originalPath = "/usr/bin/processing-java"
28+
29+
expect(escapeExecutablePath(originalPath)).toBe("/usr/bin/processing-java")
30+
})
31+
32+
it("should not escape already escaped spaces on Windows", () => {
33+
const originalPath = "C:\\Program` Files\\processing\\processing java"
34+
35+
expect(escapeExecutablePath(originalPath)).toBe(
36+
"C:\\Program` Files\\processing\\processing` java",
37+
)
38+
})
39+
40+
it("should not escape already escaped spaces on Unix", () => {
41+
const originalPath = "/usr/bin/something else/processing\\ java"
42+
43+
expect(escapeExecutablePath(originalPath)).toBe(
44+
"/usr/bin/something\\ else/processing\\ java",
45+
)
46+
})
47+
48+
it("should detect platform if no path seperators available", () => {
49+
const originalPath = "processing java"
50+
51+
if (process.platform === "win32") {
52+
expect(escapeExecutablePath(originalPath)).toBe("processing` java")
53+
} else {
54+
expect(escapeExecutablePath(originalPath)).toBe("processing\\ java")
55+
}
56+
})
57+
58+
it("should leave single path as is", () => {
59+
const originalPath = "processing-java"
60+
61+
expect(escapeExecutablePath(originalPath)).toBe("processing-java")
62+
})
63+
})

__tests__/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @type {import("ts-jest/dist/types").InitialOptionsTsJest}
3+
*/
4+
module.exports = {
5+
preset: "ts-jest",
6+
testEnvironment: "node",
7+
}

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "processing-vscode",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"private": true,
55
"description": "Processing Language Support for VSCode",
66
"license": "MIT",
@@ -19,6 +19,7 @@
1919
"deploy": "vsce publish",
2020
"format": "prettier . --write && eslint --ext ts --fix --cache",
2121
"lint": "eslint --ext ts src --max-warnings 0 --cache",
22+
"test": "node --experimental-vm-modules --experimental-specifier-resolution=node node_modules/.bin/jest",
2223
"vscode:prepublish": "rollup -c rollup.config.js"
2324
},
2425
"keywords": [
@@ -35,6 +36,7 @@
3536
"@rollup/plugin-node-resolve": "^13.0.0",
3637
"@rollup/plugin-typescript": "^8.2.1",
3738
"@types/glob": "^7.1.4",
39+
"@types/jest": "^27.0.3",
3840
"@types/jsdom": "^16.2.13",
3941
"@types/node": "^16.3.1",
4042
"@types/node-fetch": "^2.5.11",
@@ -44,6 +46,7 @@
4446
"eslint": "^7.30.0",
4547
"eslint-plugin-prefer-arrow": "^1.2.3",
4648
"glob": "^7.1.7",
49+
"jest": "^27.4.5",
4750
"jsdom": "^16.6.0",
4851
"node-fetch": "^2.6.1",
4952
"prettier": "^2.3.2",
@@ -52,6 +55,7 @@
5255
"rollup": "^2.53.0",
5356
"rollup-plugin-progress": "^1.1.2",
5457
"rollup-plugin-terser": "^7.0.2",
58+
"ts-jest": "^27.1.2",
5559
"tslib": "^2.3.0",
5660
"typescript": "~4.3.5",
5761
"vsce": "^1.95.1",
@@ -172,6 +176,12 @@
172176
"default": "processing-java",
173177
"description": "Path to Processing. Leave default if you've added processing to your path, otherwise enter the path to `processing-java` here. Example: `/usr/bin/processing-java` for Unix, or `C:\\Program Files\\processing-3.0.1\\processing-java` for Windows."
174178
},
179+
"processing.path": {
180+
"type": "string",
181+
"default": "processing-java",
182+
"description": "Legacy path to Processing. Use processing.processingPath instead. If processing.processingPath is available, it will be used",
183+
"deprecationMessage": "Legacy path to Processing. Use processing.processingPath instead. If processing.processingPath is available, it will be used"
184+
},
175185
"processing.docs": {
176186
"type": "string",
177187
"default": "auto",

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const banner = `/**
99
* https://github.com/Luke-zhang-04/processing-vscode
1010
*
1111
* @license MIT
12-
* @version 2.5.0
12+
* @version 2.5.1
1313
* @preserve
1414
* @copyright (C) 2016 - 2020 Tobiah Zarlez, 2021 Luke Zhang
1515
*

src/config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
* @copyright (C) 2021 Luke Zhang
55
*/
66

7+
import {escapeExecutablePath} from "./utils"
78
import vscode from "vscode"
89

910
const getProcessingCommand = (): string => {
11+
// Look for processing.processingPath, then processing.path, then default to processing-java
1012
const config = vscode.workspace
1113
.getConfiguration()
12-
.get<unknown>("processing.processingPath", "processing-java")
14+
.get<unknown>(
15+
"processing.processingPath",
16+
vscode.workspace.getConfiguration().get<unknown>("processing.path", "processing-java"),
17+
)
1318

1419
if (typeof config !== "string") {
1520
const msg = "Config option processing.processingPath must be of type string"
@@ -19,7 +24,7 @@ const getProcessingCommand = (): string => {
1924
return "processing-java"
2025
}
2126

22-
return config
27+
return escapeExecutablePath(config)
2328
}
2429

2530
const getJavaCommand = (): string => {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Processing-vscode - Processing Language Support for VSCode
33
*
4-
* @version 2.5.0
4+
* @version 2.5.1
55
* @copyright (C) 2016 - 2020 Tobiah Zarlez, 2021 Luke Zhang
66
*/
77

0 commit comments

Comments
 (0)