This repository was archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy patharduino.ts
665 lines (588 loc) · 26.3 KB
/
arduino.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as fs from "fs";
import * as glob from "glob";
import * as os from "os";
import * as path from "path";
import * as vscode from "vscode";
import * as constants from "../common/constants";
import * as util from "../common/util";
import * as Logger from "../logger/logger";
import { DeviceContext } from "../deviceContext";
import { IArduinoSettings } from "./arduinoSettings";
import { BoardManager } from "./boardManager";
import { ExampleManager } from "./exampleManager";
import { LibraryManager } from "./libraryManager";
import { VscodeSettings } from "./vscodeSettings";
import { arduinoChannel } from "../common/outputChannel";
import { ArduinoWorkspace } from "../common/workspace";
import { SerialMonitor } from "../serialmonitor/serialMonitor";
import { UsbDetector } from "../serialmonitor/usbDetector";
import { ProgrammerManager } from "./programmerManager";
/**
* Represent an Arduino application based on the official Arduino IDE.
*/
export class ArduinoApp {
private _boardManager: BoardManager;
private _libraryManager: LibraryManager;
private _exampleManager: ExampleManager;
private _programmerManager: ProgrammerManager;
/**
* @param {IArduinoSettings} _settings ArduinoSetting object.
*/
constructor(private _settings: IArduinoSettings) {
}
/**
* Need refresh Arduino IDE's setting when starting up.
* @param {boolean} force - Whether force initialize the arduino
*/
public async initialize(force: boolean = false) {
if (!util.fileExistsSync(this._settings.preferencePath)) {
try {
// Use empty pref value to initialize preference.txt file
await this.setPref("boardsmanager.additional.urls", "");
this._settings.reloadPreferences(); // reload preferences.
} catch (ex) {
}
}
if (force || !util.fileExistsSync(path.join(this._settings.packagePath, "package_index.json"))) {
try {
// Use the dummy package to initialize the Arduino IDE
await this.installBoard("dummy", "", "", true);
} catch (ex) {
}
}
}
/**
* Initialize the arduino library.
* @param {boolean} force - Whether force refresh library index file
*/
public async initializeLibrary(force: boolean = false) {
if (force || !util.fileExistsSync(path.join(this._settings.packagePath, "library_index.json"))) {
try {
// Use the dummy library to initialize the Arduino IDE
await this.installLibrary("dummy", "", true);
} catch (ex) {
}
}
}
/**
* Set the Arduino preferences value.
* @param {string} key - The preference key
* @param {string} value - The preference value
*/
public async setPref(key, value) {
try {
await util.spawn(this._settings.commandPath,
null,
["--pref", `${key}=${value}`, "--save-prefs"]);
} catch (ex) {
}
}
public async upload() {
const dc = DeviceContext.getInstance();
const boardDescriptor = this.getBoardBuildString();
if (!boardDescriptor) {
return;
}
if (!ArduinoWorkspace.rootPath) {
vscode.window.showWarningMessage("Cannot find the sketch file.");
return;
}
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
await this.getMainSketch(dc);
}
if (!dc.uploadPort) {
vscode.window.showErrorMessage("Please specify the upload port.");
return;
}
arduinoChannel.show();
arduinoChannel.start(`Upload sketch - ${dc.sketch}`);
let serialMonitor;
let needRestore = false;
if (dc.port === dc.uploadPort) {
serialMonitor = SerialMonitor.getInstance();
needRestore = await serialMonitor.closeSerialMonitor(dc.port);
}
UsbDetector.getInstance().pauseListening();
await vscode.workspace.saveAll(false);
if (dc.prebuild) {
arduinoChannel.info(`Run prebuild command: ${dc.prebuild}`);
const prebuildargs = dc.prebuild.split(" ");
const prebuildCommand = prebuildargs.shift();
try {
await util.spawn(prebuildCommand, arduinoChannel.channel, prebuildargs, {shell: true, cwd: ArduinoWorkspace.rootPath});
} catch (ex) {
arduinoChannel.error(`Run prebuild failed: \n${ex.error}`);
return;
}
}
const appPath = path.join(ArduinoWorkspace.rootPath, dc.sketch);
const args = ["--upload", "--board", boardDescriptor, "--port", dc.uploadPort, appPath];
if (VscodeSettings.getInstance().logLevel === "verbose") {
args.push("--verbose");
}
if (dc.output) {
const outputPath = path.resolve(ArduinoWorkspace.rootPath, dc.output);
args.push("--pref", `build.path=${outputPath}`);
} else {
const msg = "Output path is not specified. Unable to reuse previously compiled files. Upload could be slow. See README.";
arduinoChannel.warning(msg);
}
await util.spawn(this._settings.commandPath, arduinoChannel.channel, args).then(async () => {
UsbDetector.getInstance().resumeListening();
if (needRestore) {
await serialMonitor.openSerialMonitor();
}
arduinoChannel.end(`Uploaded the sketch: ${dc.sketch}${os.EOL}`);
}, (reason) => {
arduinoChannel.error(`Exit with code=${reason.code}${os.EOL}`);
});
}
public async uploadUsingProgrammer() {
const dc = DeviceContext.getInstance();
const boardDescriptor = this.getBoardBuildString();
if (!boardDescriptor) {
return;
}
const selectProgrammer = this.getProgrammerString();
if (!selectProgrammer) {
return;
}
if (!ArduinoWorkspace.rootPath) {
vscode.window.showWarningMessage("Cannot find the sketch file.");
return;
}
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
await this.getMainSketch(dc);
}
if (!dc.port) {
vscode.window.showErrorMessage("Please specify the upload serial port.");
return;
}
arduinoChannel.show();
arduinoChannel.start(`Upload sketch - ${dc.sketch}`);
const serialMonitor = SerialMonitor.getInstance();
const needRestore = await serialMonitor.closeSerialMonitor(dc.port);
UsbDetector.getInstance().pauseListening();
await vscode.workspace.saveAll(false);
const appPath = path.join(ArduinoWorkspace.rootPath, dc.sketch);
const args = ["--upload", "--board", boardDescriptor, "--port", dc.port, "--useprogrammer",
"--pref", "programmer=" + selectProgrammer, appPath];
if (VscodeSettings.getInstance().logLevel === "verbose") {
args.push("--verbose");
}
if (dc.output) {
const outputPath = path.resolve(ArduinoWorkspace.rootPath, dc.output);
args.push("--pref", `build.path=${outputPath}`);
} else {
const msg = "Output path is not specified. Unable to reuse previously compiled files. Upload could be slow. See README.";
arduinoChannel.warning(msg);
}
await util.spawn(this._settings.commandPath, arduinoChannel.channel, args).then(async () => {
UsbDetector.getInstance().resumeListening();
if (needRestore) {
await serialMonitor.openSerialMonitor();
}
arduinoChannel.end(`Uploaded the sketch: ${dc.sketch}${os.EOL}`);
}, (reason) => {
arduinoChannel.error(`Exit with code=${reason.code}${os.EOL}`);
});
}
public async verify(output: string = "") {
const dc = DeviceContext.getInstance();
const boardDescriptor = this.getBoardBuildString();
if (!boardDescriptor) {
return;
}
if (!ArduinoWorkspace.rootPath) {
vscode.window.showWarningMessage("Cannot find the sketch file.");
return;
}
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
await this.getMainSketch(dc);
}
await vscode.workspace.saveAll(false);
arduinoChannel.start(`Verify sketch - ${dc.sketch}`);
if (dc.prebuild) {
arduinoChannel.info(`Run prebuild command: ${dc.prebuild}`);
const prebuildargs = dc.prebuild.split(" ");
const prebuildCommand = prebuildargs.shift();
try {
await util.spawn(prebuildCommand, arduinoChannel.channel, prebuildargs, {shell: true, cwd: ArduinoWorkspace.rootPath});
} catch (ex) {
arduinoChannel.error(`Run prebuild failed: \n${ex.error}`);
return;
}
}
const appPath = path.join(ArduinoWorkspace.rootPath, dc.sketch);
const args = ["--verify", "--board", boardDescriptor, appPath];
if (VscodeSettings.getInstance().logLevel === "verbose") {
args.push("--verbose");
}
if (output || dc.output) {
const outputPath = path.resolve(ArduinoWorkspace.rootPath, output || dc.output);
args.push("--pref", `build.path=${outputPath}`);
} else {
const msg = "Output path is not specified. Unable to reuse previously compiled files. Verify could be slow. See README.";
arduinoChannel.warning(msg);
}
arduinoChannel.show();
// we need to return the result of verify
try {
await util.spawn(this._settings.commandPath, arduinoChannel.channel, args);
arduinoChannel.end(`Finished verify sketch - ${dc.sketch}${os.EOL}`);
return true;
} catch (reason) {
arduinoChannel.error(`Exit with code=${reason.code}${os.EOL}`);
return false;
}
}
// Add selected library path to the intellisense search path.
public addLibPath(libraryPath: string) {
let libPaths;
if (libraryPath) {
libPaths = [libraryPath];
} else {
libPaths = this.getDefaultPackageLibPaths();
}
const defaultForcedInclude = this.getDefaultForcedIncludeFiles();
if (!ArduinoWorkspace.rootPath) {
return;
}
const configFilePath = path.join(ArduinoWorkspace.rootPath, constants.CPP_CONFIG_FILE);
let deviceContext = null;
if (!util.fileExistsSync(configFilePath)) {
util.mkdirRecursivelySync(path.dirname(configFilePath));
deviceContext = {};
} else {
deviceContext = util.tryParseJSON(fs.readFileSync(configFilePath, "utf8"));
}
if (!deviceContext) {
Logger.notifyAndThrowUserError("arduinoFileError", new Error(constants.messages.ARDUINO_FILE_ERROR));
}
deviceContext.configurations = deviceContext.configurations || [];
let configSection = null;
deviceContext.configurations.forEach((section) => {
if (section.name === util.getCppConfigPlatform()) {
configSection = section;
}
});
if (!configSection) {
configSection = {
name: util.getCppConfigPlatform(),
includePath: [],
};
deviceContext.configurations.push(configSection);
}
libPaths.forEach((childLibPath) => {
childLibPath = path.resolve(path.normalize(childLibPath));
if (configSection.includePath && configSection.includePath.length) {
for (const existingPath of configSection.includePath) {
if (childLibPath === path.resolve(path.normalize(existingPath))) {
return;
}
}
} else {
configSection.includePath = [];
}
configSection.includePath.unshift(childLibPath);
});
if (!configSection.forcedInclude) {
configSection.forcedInclude = defaultForcedInclude;
} else {
for (let i = 0; i < configSection.forcedInclude.length; i++) {
if (/arduino\.h$/i.test(configSection.forcedInclude[i])) {
configSection.forcedInclude.splice(i, 1);
i--;
}
}
configSection.forcedInclude = defaultForcedInclude.concat(configSection.forcedInclude);
}
fs.writeFileSync(configFilePath, JSON.stringify(deviceContext, null, 4));
}
// Include the *.h header files from selected library to the arduino sketch.
public async includeLibrary(libraryPath: string) {
if (!ArduinoWorkspace.rootPath) {
return;
}
const dc = DeviceContext.getInstance();
const appPath = path.join(ArduinoWorkspace.rootPath, dc.sketch);
if (util.fileExistsSync(appPath)) {
const hFiles = glob.sync(`${libraryPath}/*.h`, {
nodir: true,
matchBase: true,
});
const hIncludes = hFiles.map((hFile) => {
return `#include <${path.basename(hFile)}>`;
}).join(os.EOL);
// Open the sketch and bring up it to current visible view.
const textDocument = await vscode.workspace.openTextDocument(appPath);
await vscode.window.showTextDocument(textDocument, vscode.ViewColumn.One, true);
const activeEditor = vscode.window.visibleTextEditors.find((textEditor) => {
return path.resolve(textEditor.document.fileName) === path.resolve(appPath);
});
if (activeEditor) {
// Insert *.h at the beginning of the sketch code.
await activeEditor.edit((editBuilder) => {
editBuilder.insert(new vscode.Position(0, 0), `${hIncludes}${os.EOL}${os.EOL}`);
});
}
}
}
/**
* Install arduino board package based on package name and platform hardware architecture.
*/
public async installBoard(packageName: string, arch: string = "", version: string = "", showOutput: boolean = true) {
arduinoChannel.show();
const updatingIndex = packageName === "dummy" && !arch && !version;
if (updatingIndex) {
arduinoChannel.start(`Update package index files...`);
} else {
try {
const packagePath = path.join(this._settings.packagePath, "packages", packageName);
if (util.directoryExistsSync(packagePath)) {
util.rmdirRecursivelySync(packagePath);
}
arduinoChannel.start(`Install package - ${packageName}...`);
} catch (error) {
arduinoChannel.start(`Install package - ${packageName} failed under directory : ${error.path}${os.EOL}
Please make sure the folder is not occupied by other procedures .`);
arduinoChannel.error(`Error message - ${error.message}${os.EOL}`);
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
return;
}
}
try {
await util.spawn(this._settings.commandPath,
showOutput ? arduinoChannel.channel : null,
["--install-boards", `${packageName}${arch && ":" + arch}${version && ":" + version}`]);
if (updatingIndex) {
arduinoChannel.end("Updated package index files.");
} else {
arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
}
} catch (error) {
// If a platform with the same version is already installed, nothing is installed and program exits with exit code 1
if (error.code === 1) {
if (updatingIndex) {
arduinoChannel.end("Updated package index files.");
} else {
arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
}
} else {
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
}
}
}
public uninstallBoard(boardName: string, packagePath: string) {
arduinoChannel.start(`Uninstall board package - ${boardName}...`);
util.rmdirRecursivelySync(packagePath);
arduinoChannel.end(`Uninstalled board package - ${boardName}${os.EOL}`);
}
public async installLibrary(libName: string, version: string = "", showOutput: boolean = true) {
arduinoChannel.show();
const updatingIndex = (libName === "dummy" && !version);
if (updatingIndex) {
arduinoChannel.start("Update library index files...");
} else {
arduinoChannel.start(`Install library - ${libName}`);
}
try {
await util.spawn(this._settings.commandPath,
showOutput ? arduinoChannel.channel : null,
["--install-library", `${libName}${version && ":" + version}`]);
if (updatingIndex) {
arduinoChannel.end("Updated library index files.");
} else {
arduinoChannel.end(`Installed library - ${libName}${os.EOL}`);
}
} catch (error) {
// If a library with the same version is already installed, nothing is installed and program exits with exit code 1
if (error.code === 1) {
if (updatingIndex) {
arduinoChannel.end("Updated library index files.");
} else {
arduinoChannel.end(`Installed library - ${libName}${os.EOL}`);
}
} else {
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
}
}
}
public uninstallLibrary(libName: string, libPath: string) {
arduinoChannel.start(`Remove library - ${libName}`);
util.rmdirRecursivelySync(libPath);
arduinoChannel.end(`Removed library - ${libName}${os.EOL}`);
}
public getDefaultPackageLibPaths(): string[] {
const result = [];
const boardDescriptor = this._boardManager.currentBoard;
if (!boardDescriptor) {
return result;
}
const toolsPath = boardDescriptor.platform.rootBoardPath;
result.push(path.normalize(path.join(toolsPath, "**")));
// if (util.directoryExistsSync(path.join(toolsPath, "cores"))) {
// const coreLibs = fs.readdirSync(path.join(toolsPath, "cores"));
// if (coreLibs && coreLibs.length > 0) {
// coreLibs.forEach((coreLib) => {
// result.push(path.normalize(path.join(toolsPath, "cores", coreLib)));
// });
// }
// }
// return result;
// <package>/hardware/<platform>/<version> -> <package>/tools
const toolPath = path.join(toolsPath, "..", "..", "..", "tools");
if (fs.existsSync(toolPath)) {
result.push(path.normalize(path.join(toolPath, "**")));
}
return result;
}
public getDefaultForcedIncludeFiles(): string[] {
const result = [];
const boardDescriptor = this._boardManager.currentBoard;
if (!boardDescriptor) {
return result;
}
const arduinoHeadFilePath = path.normalize(path.join(boardDescriptor.platform.rootBoardPath, "cores", "arduino", "Arduino.h"));
if (fs.existsSync(arduinoHeadFilePath)) {
result.push(arduinoHeadFilePath);
}
return result;
}
public openExample(example) {
function tmpName(name) {
let counter = 0;
let candidateName = name;
while (true) {
if (!util.fileExistsSync(candidateName) && !util.directoryExistsSync(candidateName)) {
return candidateName;
}
counter++;
candidateName = `${name}_${counter}`;
}
}
// Step 1: Copy the example project to a temporary directory.
const sketchPath = path.join(this._settings.sketchbookPath, "generated_examples");
if (!util.directoryExistsSync(sketchPath)) {
util.mkdirRecursivelySync(sketchPath);
}
let destExample = "";
if (util.directoryExistsSync(example)) {
destExample = tmpName(path.join(sketchPath, path.basename(example)));
util.cp(example, destExample);
} else if (util.fileExistsSync(example)) {
const exampleName = path.basename(example, path.extname(example));
destExample = tmpName(path.join(sketchPath, exampleName));
util.mkdirRecursivelySync(destExample);
util.cp(example, path.join(destExample, path.basename(example)));
}
if (destExample) {
// Step 2: Scaffold the example project to an arduino project.
const items = fs.readdirSync(destExample);
const sketchFile = items.find((item) => {
return util.isArduinoFile(path.join(destExample, item));
});
if (sketchFile) {
// Generate arduino.json
const dc = DeviceContext.getInstance();
const arduinoJson = {
sketch: sketchFile,
port: dc.port || "COM1",
board: dc.board,
configuration: dc.configuration,
};
const arduinoConfigFilePath = path.join(destExample, constants.ARDUINO_CONFIG_FILE);
util.mkdirRecursivelySync(path.dirname(arduinoConfigFilePath));
fs.writeFileSync(arduinoConfigFilePath, JSON.stringify(arduinoJson, null, 4));
// Generate cpptools intellisense config
const cppConfigFilePath = path.join(destExample, constants.CPP_CONFIG_FILE);
// Current workspace
let includePath = ["${workspaceRoot}"];
// Defaut package for this board
const defaultPackageLibPaths = this.getDefaultPackageLibPaths();
includePath = includePath.concat(defaultPackageLibPaths);
// Arduino built-in package tools
includePath.push(path.join(this._settings.arduinoPath, "hardware", "tools", "**"));
// Arduino built-in libraries
includePath.push(path.join(this._settings.arduinoPath, "libraries", "**"));
// Arduino custom package tools
includePath.push(path.join(os.homedir(), "Documents", "Arduino", "hardware", "tools", "**"));
// Arduino custom libraries
includePath.push(path.join(os.homedir(), "Documents", "Arduino", "libraries", "**"));
const forcedInclude = this.getDefaultForcedIncludeFiles();
const defines = [
"ARDUINO=10800",
];
const cppConfig = {
configurations: [{
name: util.getCppConfigPlatform(),
defines,
includePath,
forcedInclude,
intelliSenseMode: "clang-x64",
cStandard: "c11",
cppStandard: "c++17",
}],
version: 3,
};
util.mkdirRecursivelySync(path.dirname(cppConfigFilePath));
fs.writeFileSync(cppConfigFilePath, JSON.stringify(cppConfig, null, 4));
}
// Step 3: Open the arduino project at a new vscode window.
vscode.commands.executeCommand("vscode.openFolder", vscode.Uri.file(destExample), true);
}
return destExample;
}
public get settings() {
return this._settings;
}
public get boardManager() {
return this._boardManager;
}
public set boardManager(value: BoardManager) {
this._boardManager = value;
}
public get libraryManager() {
return this._libraryManager;
}
public set libraryManager(value: LibraryManager) {
this._libraryManager = value;
}
public get exampleManager() {
return this._exampleManager;
}
public set exampleManager(value: ExampleManager) {
this._exampleManager = value;
}
public get programmerManager() {
return this._programmerManager;
}
public set programmerManager(value: ProgrammerManager) {
this._programmerManager = value;
}
private getProgrammerString(): string {
const selectProgrammer = this.programmerManager.currentProgrammer;
if (!selectProgrammer) {
Logger.notifyUserError("getProgrammerString", new Error(constants.messages.NO_PROGRAMMMER_SELECTED));
return;
}
return selectProgrammer;
}
private getBoardBuildString(): string {
const selectedBoard = this.boardManager.currentBoard;
if (!selectedBoard) {
Logger.notifyUserError("getBoardBuildString", new Error(constants.messages.NO_BOARD_SELECTED));
return;
}
return selectedBoard.getBuildConfig();
}
private async getMainSketch(dc: DeviceContext) {
await dc.resolveMainSketch();
if (!dc.sketch) {
vscode.window.showErrorMessage("No sketch file was found. Please specify the sketch in the arduino.json file");
throw new Error("No sketch file was found.");
}
}
}