Skip to content

Commit 53271ab

Browse files
committed
chore: fix linting errors
1 parent cbd3f64 commit 53271ab

File tree

9 files changed

+102
-156
lines changed

9 files changed

+102
-156
lines changed

commitlint.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const Configuration = {
2-
extends: ["@commitlint/config-conventional"],
2+
extends: ['@commitlint/config-conventional'],
33
};
44

55
export default Configuration;

config/pynsist.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
{
22
"comments": {
33
"lineComment": "#",
4-
"blockComment": [ "#", "" ]
4+
"blockComment": ["#", ""]
55
},
6-
"brackets": [
7-
["{", "}"],
8-
["[", "]"],
9-
["(", ")"]
10-
],
6+
"brackets": [["{", "}"], ["[", "]"], ["(", ")"]],
117
"autoClosingPairs": [
128
["{", "}"],
139
["[", "]"],
@@ -22,4 +18,4 @@
2218
["\"", "\""],
2319
["'", "'"]
2420
]
25-
}
21+
}

gulpfile.mjs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
'use strict';
2-
31
// Dependencies
42
import gulp from 'gulp';
53
import raster from 'gulp-raster';
64
import rename from 'gulp-rename';
75

8-
const svgFiles = [
9-
'./src/logo.svg'
10-
];
6+
const svgFiles = ['./src/logo.svg'];
117

128
// Convert SVG
139
gulp.task('default', (done) => {
14-
gulp.src(svgFiles)
15-
.pipe(raster())
16-
.pipe(rename("logo.png"))
17-
.pipe(gulp.dest('./resources'));
18-
done();
10+
gulp.src(svgFiles).pipe(raster()).pipe(rename('logo.png')).pipe(gulp.dest('./resources'));
11+
done();
1912
});

package.nls.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"pynsistAlwaysShowOutput": "If `false` the output channel will only be shown on errors",
3-
"pynsistPathToPynsist": "Specify the full path to `pynsist`",
4-
"pynsistUseWineToRun": "Specify whether to run compiled installers using [Wine](https://www.winehq.org/)"
2+
"pynsistAlwaysShowOutput": "If `false` the output channel will only be shown on errors",
3+
"pynsistPathToPynsist": "Specify the full path to `pynsist`",
4+
"pynsistUseWineToRun": "Specify whether to run compiled installers using [Wine](https://www.winehq.org/)"
55
}

src/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
import { commands, type ExtensionContext } from "vscode";
2-
import { createTask } from "./task";
3-
import { generate } from "./pynsist";
1+
import { type ExtensionContext, commands } from 'vscode';
2+
import { generate } from './pynsist';
3+
import { createTask } from './task';
44

55
export async function activate(context: ExtensionContext): Promise<void> {
66
context.subscriptions.push(
7-
commands.registerTextEditorCommand("extension.pynsist.generate", () => {
7+
commands.registerTextEditorCommand('extension.pynsist.generate', () => {
88
generate(false);
99
}),
1010
);
1111
context.subscriptions.push(
12-
commands.registerTextEditorCommand("extension.pynsist.compile", () => {
12+
commands.registerTextEditorCommand('extension.pynsist.compile', () => {
1313
generate(true);
1414
}),
1515
);
1616
context.subscriptions.push(
17-
commands.registerTextEditorCommand(
18-
"extension.pynsist.create-build-task",
19-
() => {
20-
createTask();
21-
},
22-
),
17+
commands.registerTextEditorCommand('extension.pynsist.create-build-task', () => {
18+
createTask();
19+
}),
2320
);
2421
}

src/pynsist.ts

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
import { dirname } from "path";
1+
import { spawn } from 'node:child_process';
2+
import { dirname } from 'node:path';
3+
import { window, workspace } from 'vscode';
24
// @ts-expect-error TODO Fix package
3-
import { getConfig } from "vscode-get-config";
4-
import { spawn } from "child_process";
5-
import { workspace, window } from "vscode";
5+
import { getConfig } from 'vscode-get-config';
66

7-
import {
8-
clearOutput,
9-
detectOutput,
10-
getPath,
11-
pathWarning,
12-
runInstaller,
13-
sanitize,
14-
} from "./util";
7+
import { clearOutput, detectOutput, getPath, pathWarning, runInstaller, sanitize } from './util';
158

16-
const channel = window.createOutputChannel("pynsist");
9+
const channel = window.createOutputChannel('pynsist');
1710

1811
/*
1912
* Requires pynsist
@@ -26,107 +19,91 @@ export async function generate(runMakensis: boolean): Promise<void> {
2619
const doc = window?.activeTextEditor?.document;
2720

2821
if (!doc) {
29-
console.error("[idleberg.applescript] Document not found");
22+
console.error('[idleberg.applescript] Document not found');
3023
return;
3124
}
3225

3326
const scope = doc.languageId;
3427

35-
if (scope !== "properties" && doc.fileName === "installer.cfg") {
36-
channel.appendLine(
37-
"This command is only available for Pynsist Configuration files",
38-
);
28+
if (scope !== 'properties' && doc.fileName === 'installer.cfg') {
29+
channel.appendLine('This command is only available for Pynsist Configuration files');
3930
return;
4031
}
4132

42-
const { showNotifications } = await getConfig("pynsist");
33+
const { showNotifications } = await getConfig('pynsist');
4334

4435
doc.save().then(async () => {
4536
await getPath()
4637
.then((path) => sanitize(path.toString()))
4738
.then((pathToPynsist: string) => {
48-
if (typeof pathToPynsist === "undefined" || pathToPynsist === null) {
49-
return window.showErrorMessage(
50-
"No valid `pynsist` was specified in your config",
51-
);
39+
if (typeof pathToPynsist === 'undefined' || pathToPynsist === null) {
40+
return window.showErrorMessage('No valid `pynsist` was specified in your config');
5241
}
5342

5443
const defaultArguments: Array<string> = [doc.fileName];
5544

5645
if (runMakensis === false) {
57-
defaultArguments.push("--no-makensis");
46+
defaultArguments.push('--no-makensis');
5847
}
5948

6049
// Let's build
6150
const pynsist = spawn(pathToPynsist, defaultArguments);
6251

6352
const scriptPath: string = dirname(doc.fileName);
64-
let outScript = "";
65-
let outFile = "";
53+
let outScript = '';
54+
let outFile = '';
6655

67-
pynsist.stdout.on("data", (line: string) => {
56+
pynsist.stdout.on('data', (line: string) => {
6857
channel.appendLine(line.toString().trim());
6958
});
7059

7160
// pynsist currently outputs to stderr only (v1.12)
72-
pynsist.stderr.on("data", async (line: string) => {
61+
pynsist.stderr.on('data', async (line: string) => {
7362
channel.appendLine(line.toString().trim());
7463

75-
if (outScript === "") {
64+
if (outScript === '') {
7665
outScript = await detectOutput(scriptPath, line, {
77-
string: "Writing NSI file to ",
66+
string: 'Writing NSI file to ',
7867
regex: /Writing NSI file to (.*)\r?\n/g,
7968
});
8069
}
8170

82-
if (outFile === "" && runMakensis === true) {
71+
if (outFile === '' && runMakensis === true) {
8372
outFile = await detectOutput(scriptPath, line, {
84-
string: "Installer written to ",
73+
string: 'Installer written to ',
8574
regex: /Installer written to (.*)\r?\n/g,
8675
});
8776
}
8877
});
8978

90-
pynsist.on("close", async (code) => {
79+
pynsist.on('close', async (code) => {
9180
if (code === 0) {
9281
if (showNotifications) {
9382
if (runMakensis === true) {
9483
window
95-
.showInformationMessage(
96-
"Successfully compiled installer",
97-
"Run Installer",
98-
"Open Script",
99-
)
84+
.showInformationMessage('Successfully compiled installer', 'Run Installer', 'Open Script')
10085
.then(async (choice) => {
101-
if (choice === "Run Installer") {
86+
if (choice === 'Run Installer') {
10287
await runInstaller(outFile);
103-
} else if (choice === "Open Script") {
88+
} else if (choice === 'Open Script') {
10489
workspace.openTextDocument(outScript).then((doc) => {
10590
window.showTextDocument(doc);
10691
});
10792
}
10893
});
10994
} else {
110-
window
111-
.showInformationMessage(
112-
"Successfully generated script",
113-
"Open Script",
114-
)
115-
.then((choice) => {
116-
if (choice === "Open Script") {
117-
workspace.openTextDocument(outScript).then((doc) => {
118-
window.showTextDocument(doc);
119-
});
120-
}
121-
});
95+
window.showInformationMessage('Successfully generated script', 'Open Script').then((choice) => {
96+
if (choice === 'Open Script') {
97+
workspace.openTextDocument(outScript).then((doc) => {
98+
window.showTextDocument(doc);
99+
});
100+
}
101+
});
122102
}
123103
}
124104
} else {
125105
channel.show();
126-
if (showNotifications)
127-
window.showErrorMessage(
128-
"Something went wrong. See the output for details.",
129-
);
106+
if (showNotifications) window.showErrorMessage('Something went wrong. See the output for details.');
130107
}
131108
});
132109
})

src/task.ts

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1+
import { mkdir, writeFile } from 'node:fs';
2+
import { join, resolve } from 'node:path';
3+
import { window, workspace } from 'vscode';
14
// @ts-expect-error TODO Fix package
2-
import { getConfig } from "vscode-get-config";
3-
import { join, resolve } from "path";
4-
import { mkdir, writeFile } from "fs";
5-
import { workspace, window } from "vscode";
6-
import { getPath, sanitize } from "./util";
5+
import { getConfig } from 'vscode-get-config';
6+
import { getPath, sanitize } from './util';
77

88
export async function createTask(): Promise<void> {
9-
if (
10-
typeof workspace.workspaceFolders === "undefined" ||
11-
workspace.workspaceFolders.length < 1
12-
) {
9+
if (typeof workspace.workspaceFolders === 'undefined' || workspace.workspaceFolders.length < 1) {
1310
window.showErrorMessage(
14-
"Task support is only available when working on a workspace folder. It is not available when editing single files.",
11+
'Task support is only available when working on a workspace folder. It is not available when editing single files.',
1512
);
1613
return;
1714
}
@@ -20,31 +17,28 @@ export async function createTask(): Promise<void> {
2017
.then((path) => sanitize(path.toString()))
2118
.then(async (pathToPynsist: string) => {
2219
const taskFile: unknown = {
23-
version: "2.0.0",
20+
version: '2.0.0',
2421
tasks: [
2522
{
26-
label: "pynsist: Compile Installer",
27-
type: "shell",
23+
label: 'pynsist: Compile Installer',
24+
type: 'shell',
2825
command: `${pathToPynsist}`,
29-
args: ["${file}"],
30-
group: "build",
26+
args: ['${file}'],
27+
group: 'build',
3128
},
3229
{
33-
label: "pynsist: Generate Script",
34-
type: "shell",
30+
label: 'pynsist: Generate Script',
31+
type: 'shell',
3532
command: `${pathToPynsist}`,
36-
args: ["--no-makensis", "${file}"],
37-
group: "build",
33+
args: ['--no-makensis', '${file}'],
34+
group: 'build',
3835
},
3936
],
4037
};
4138

4239
const jsonString: string = JSON.stringify(taskFile, null, 2);
43-
const dotFolder: string = resolve(
44-
workspace.workspaceFolders![0]!.uri.fsPath,
45-
".vscode",
46-
);
47-
const buildFile: string = join(dotFolder, "tasks.json");
40+
const dotFolder: string = resolve(workspace.workspaceFolders?.[0]?.uri.fsPath, '.vscode');
41+
const buildFile: string = join(dotFolder, 'tasks.json');
4842

4943
mkdir(dotFolder, () => {
5044
// ignore errors for now
@@ -53,8 +47,7 @@ export async function createTask(): Promise<void> {
5347
window.showErrorMessage(error.toString());
5448
return;
5549
}
56-
if ((await getConfig("pynsist.alwaysOpenBuildTask")) === false)
57-
return;
50+
if ((await getConfig('pynsist.alwaysOpenBuildTask')) === false) return;
5851

5952
// Open tasks.json
6053
workspace.openTextDocument(buildFile).then((doc) => {

0 commit comments

Comments
 (0)