Skip to content

Commit f905ec8

Browse files
authored
Merge pull request #19 from ahnafnafee/bug/fixes-18
2 parents 6c72006 + c3976e6 commit f905ec8

10 files changed

Lines changed: 92 additions & 82 deletions

File tree

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ about: Create a report to help us improve
44
title: "[BUG] "
55
labels: bug
66
assignees: ahnafnafee
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -24,8 +24,21 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Desktop (please complete the following information):**
27-
- OS: [e.g. Windows]
28-
- Version [e.g. 0.3.0]
27+
28+
- OS: [e.g. Windows]
29+
- Version [e.g. 0.3.0]
30+
31+
**Extension Host Logs**
32+
Please provide logs to help us debug the issue:
33+
34+
1. Open VS Code Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`)
35+
2. Run `Developer: Show Logs...`
36+
3. Select `Extension Host`
37+
4. Copy lines starting with `PostScript Preview:` or any errors that occurred around the time of the bug.
38+
39+
```text
40+
Paste logs here
41+
```
2942

3043
**Additional context**
3144
Add any other context about the problem here.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## [0.5.2] - 2025-12-17
4+
5+
- Fixed `Cannot find module 'path-scurry'` runtime error by downgrading `glob` dependency.
6+
- Fixed "Command not found" error during extension activation on Windows (caused by `showWhatsNew` crash).
7+
38
## [0.5.0] - 2025-12-15
49

510
### New Features

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "postscript-preview",
33
"displayName": "PostScript Preview",
44
"description": "PostScript Preview is an extension that helps to preview EPS and PS files in Visual Studio Code.",
5-
"version": "0.5.1",
5+
"version": "0.5.2",
66
"icon": "images/logo.png",
77
"publisher": "ahnafnafee",
88
"engines": {
@@ -26,7 +26,6 @@
2626
"preview"
2727
],
2828
"activationEvents": [
29-
"onCommand:postscript-preview.sidePreview",
3029
"onLanguage:postscript"
3130
],
3231
"main": "./out/extension.js",
@@ -77,21 +76,20 @@
7776
"test": "node ./out/test/runTest.js"
7877
},
7978
"devDependencies": {
80-
"@types/glob": "^9.0.0",
8179
"@types/mocha": "^10.0.10",
8280
"@types/node": "^25.0.2",
8381
"@types/vscode": "^1.46.0",
8482
"@typescript-eslint/eslint-plugin": "^8.50.0",
8583
"@typescript-eslint/parser": "^8.50.0",
84+
"@vscode/test-electron": "^2.4.1",
8685
"eslint": "^9.39.2",
87-
"glob": "^13.0.0",
8886
"lodash": "^4.17.21",
8987
"mocha": "^11.7.5",
90-
"typescript": "^5.9.3",
91-
"@vscode/test-electron": "^2.4.1"
88+
"typescript": "^5.9.3"
9289
},
9390
"dependencies": {
9491
"@types/temp": "^0.9.4",
92+
"glob": "^7.2.3",
9593
"temp": "^0.9.1"
9694
},
9795
"repository": {

src/extension.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ import { showWhatsNew } from "./whats-new";
1313
* Called when the extension is activated
1414
*/
1515
export function activate(context: vscode.ExtensionContext): void {
16+
console.log("PostScript Preview: Activating extension...");
1617
const isWindows = process.platform === "win32";
1718

1819
if (isWindows) {
19-
showWhatsNew(context); // show notification in case of a minor release
20+
console.log("PostScript Preview: Checking for updates (Windows)...");
21+
showWhatsNew(context).catch((error) => {
22+
console.error(
23+
"PostScript Preview: Failed to show whats new notification:",
24+
error
25+
);
26+
});
2027
}
2128

2229
const channel = vscode.window.createOutputChannel("PostScript-Preview");
@@ -120,6 +127,7 @@ export function activate(context: vscode.ExtensionContext): void {
120127
);
121128

122129
context.subscriptions.push(disposable);
130+
console.log("PostScript Preview: Activation complete. Command registered.");
123131
}
124132

125133
/**

src/test/runTest.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ async function main() {
1212
const extensionTestsPath = path.resolve(__dirname, "./suite/index");
1313

1414
// Download VS Code, unzip it and run the integration test
15-
await runTests({ extensionDevelopmentPath, extensionTestsPath });
15+
await runTests({
16+
extensionDevelopmentPath,
17+
extensionTestsPath,
18+
launchArgs: [extensionDevelopmentPath],
19+
});
1620
} catch (err) {
1721
console.error("Failed to run tests");
1822
process.exit(1);

src/test/suite/extension.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,20 @@ suite("Extension Test Suite", () => {
2828
const commands = await vscode.commands.getCommands(true);
2929
assert.ok(commands.includes("postscript-preview.sidePreview"));
3030
});
31+
32+
test("Preview command should execute without error", async () => {
33+
// Ensure workspace is open
34+
assert.ok(vscode.workspace.workspaceFolders, "No workspace is open");
35+
36+
const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath;
37+
const filePath = vscode.Uri.file(
38+
workspaceRoot + "/examples/basic_shapes.ps"
39+
);
40+
41+
const doc = await vscode.workspace.openTextDocument(filePath);
42+
await vscode.window.showTextDocument(doc);
43+
44+
// Execute the command - validation fails if this throws
45+
await vscode.commands.executeCommand("postscript-preview.sidePreview");
46+
});
3147
});

src/test/suite/index.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from "path";
22
import * as Mocha from "mocha";
3-
import { glob } from "glob";
3+
const glob = require("glob");
44

55
export async function run(): Promise<void> {
66
// Create the mocha test
@@ -11,25 +11,34 @@ export async function run(): Promise<void> {
1111

1212
const testsRoot = path.resolve(__dirname, "..");
1313

14-
// Use glob to find all files ending in .test.js
15-
const files = await glob("**/**.test.js", { cwd: testsRoot });
14+
return new Promise((resolve, reject) => {
15+
glob(
16+
"**/**.test.js",
17+
{ cwd: testsRoot },
18+
(err: any, files: string[]) => {
19+
if (err) {
20+
return reject(err);
21+
}
1622

17-
// Add files to the test suite
18-
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
23+
// Add files to the test suite
24+
files.forEach((f: string) =>
25+
mocha.addFile(path.resolve(testsRoot, f))
26+
);
1927

20-
return new Promise((resolve, reject) => {
21-
try {
22-
// Run the mocha test
23-
mocha.run((failures) => {
24-
if (failures > 0) {
25-
reject(new Error(`${failures} tests failed.`));
26-
} else {
27-
resolve();
28+
try {
29+
// Run the mocha test
30+
mocha.run((failures) => {
31+
if (failures > 0) {
32+
reject(new Error(`${failures} tests failed.`));
33+
} else {
34+
resolve();
35+
}
36+
});
37+
} catch (err) {
38+
console.error(err);
39+
reject(err);
2840
}
29-
});
30-
} catch (err) {
31-
console.error(err);
32-
reject(err);
33-
}
41+
}
42+
);
3443
});
3544
}

src/whats-new.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ function isMajorUpdate(
3636
*/
3737
export async function showWhatsNew(context: ExtensionContext): Promise<void> {
3838
const previousVersion = context.globalState.get<string>(extensionId);
39-
const currentVersion =
40-
extensions.getExtension(extensionId)?.packageJSON.version;
39+
const extension = extensions.getExtension(extensionId);
40+
const currentVersion = extension?.packageJSON?.version;
41+
42+
if (!currentVersion) {
43+
return;
44+
}
4145

4246
// store latest version
4347
context.globalState.update(extensionId, currentVersion);

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
],
99
"sourceMap": true,
1010
"rootDir": "src",
11-
"strict": true /* enable all strict type-checking options */
11+
"strict": true, /* enable all strict type-checking options */
12+
"skipLibCheck": true,
1213
/* Additional Checks */
1314
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
1415
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
@@ -18,4 +19,4 @@
1819
"node_modules",
1920
".vscode-test"
2021
]
21-
}
22+
}

yarn.lock

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,6 @@
9393
resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.3.tgz#c2b9d2e374ee62c586d3adbea87199b1d7a7a6ba"
9494
integrity sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==
9595

96-
"@isaacs/balanced-match@^4.0.1":
97-
version "4.0.1"
98-
resolved "https://registry.yarnpkg.com/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz#3081dadbc3460661b751e7591d7faea5df39dd29"
99-
integrity sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==
100-
101-
"@isaacs/brace-expansion@^5.0.0":
102-
version "5.0.0"
103-
resolved "https://registry.yarnpkg.com/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz#4b3dabab7d8e75a429414a96bd67bf4c1d13e0f3"
104-
integrity sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==
105-
dependencies:
106-
"@isaacs/balanced-match" "^4.0.1"
107-
10896
"@isaacs/cliui@^8.0.2":
10997
version "8.0.2"
11098
resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550"
@@ -127,13 +115,6 @@
127115
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e"
128116
integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==
129117

130-
"@types/glob@^9.0.0":
131-
version "9.0.0"
132-
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-9.0.0.tgz#7b942fafe09c55671912b34f04e8e4676faf32b1"
133-
integrity sha512-00UxlRaIUvYm4R4W9WYkN8/J+kV8fmOQ7okeH6YFtGWFMt3odD45tpG5yA5wnL7HE6lLgjaTW5n14ju2hl2NNA==
134-
dependencies:
135-
glob "*"
136-
137118
"@types/json-schema@^7.0.15":
138119
version "7.0.15"
139120
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
@@ -655,15 +636,6 @@ glob-parent@^6.0.2:
655636
dependencies:
656637
is-glob "^4.0.3"
657638

658-
glob@*, glob@^13.0.0:
659-
version "13.0.0"
660-
resolved "https://registry.yarnpkg.com/glob/-/glob-13.0.0.tgz#9d9233a4a274fc28ef7adce5508b7ef6237a1be3"
661-
integrity sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==
662-
dependencies:
663-
minimatch "^10.1.1"
664-
minipass "^7.1.2"
665-
path-scurry "^2.0.0"
666-
667639
glob@^10.4.5:
668640
version "10.5.0"
669641
resolved "https://registry.yarnpkg.com/glob/-/glob-10.5.0.tgz#8ec0355919cd3338c28428a23d4f24ecc5fe738c"
@@ -676,7 +648,7 @@ glob@^10.4.5:
676648
package-json-from-dist "^1.0.0"
677649
path-scurry "^1.11.1"
678650

679-
glob@^7.1.3:
651+
glob@^7.1.3, glob@^7.2.3:
680652
version "7.2.3"
681653
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
682654
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
@@ -918,23 +890,11 @@ lru-cache@^10.2.0:
918890
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
919891
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==
920892

921-
lru-cache@^11.0.0:
922-
version "11.2.4"
923-
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.2.4.tgz#ecb523ebb0e6f4d837c807ad1abaea8e0619770d"
924-
integrity sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg==
925-
926893
mimic-function@^5.0.0:
927894
version "5.0.1"
928895
resolved "https://registry.yarnpkg.com/mimic-function/-/mimic-function-5.0.1.tgz#acbe2b3349f99b9deaca7fb70e48b83e94e67076"
929896
integrity sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==
930897

931-
minimatch@^10.1.1:
932-
version "10.1.1"
933-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.1.1.tgz#e6e61b9b0c1dcab116b5a7d1458e8b6ae9e73a55"
934-
integrity sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==
935-
dependencies:
936-
"@isaacs/brace-expansion" "^5.0.0"
937-
938898
minimatch@^3.1.1, minimatch@^3.1.2:
939899
version "3.1.2"
940900
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
@@ -1098,14 +1058,6 @@ path-scurry@^1.11.1:
10981058
lru-cache "^10.2.0"
10991059
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
11001060

1101-
path-scurry@^2.0.0:
1102-
version "2.0.1"
1103-
resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.1.tgz#4b6572376cfd8b811fca9cd1f5c24b3cbac0fe10"
1104-
integrity sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==
1105-
dependencies:
1106-
lru-cache "^11.0.0"
1107-
minipass "^7.1.2"
1108-
11091061
picocolors@^1.1.1:
11101062
version "1.1.1"
11111063
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b"

0 commit comments

Comments
 (0)