Skip to content

Commit

Permalink
Fix projectCreator, and disallow relative paths during project creation
Browse files Browse the repository at this point in the history
Closes #102
  • Loading branch information
ThadHouse committed Oct 15, 2018
1 parent ecf6335 commit f7b68a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 0 additions & 4 deletions vscode-wpilib/resources/webviews/projectcreator.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

<head>
<title>WPILib Project Create</title>
<script>
replacescript
</script>

<style>
.error {
color: red;
Expand Down
4 changes: 4 additions & 0 deletions vscode-wpilib/src/webviews/eclipseimport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class EclipseImport extends WebViewBase {
}

private async handleImport(data: IEclipseIPCData) {
if (!path.isAbsolute(data.toFolder)) {
await vscode.window.showErrorMessage('Can only extract to absolute path');
return;
}
const oldProjectPath = path.dirname(data.fromProps);

const cpp = await promisifyExists(path.join(oldProjectPath, '.cproject'));
Expand Down
6 changes: 5 additions & 1 deletion vscode-wpilib/src/webviews/projectcreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export class ProjectCreator extends WebViewBase {
}

private async createProject(data: IProjectIPCData) {
if (!path.isAbsolute(data.toFolder)) {
await vscode.window.showErrorMessage('Can only extract to absolute path');
return;
}
await this.exampleTemplateApi.createProject(data.template, data.language, data.base, data.toFolder, data.newFolder,
data.projectName, parseInt(data.teamNumber, 10));
}
Expand Down Expand Up @@ -129,6 +133,6 @@ export class ProjectCreator extends WebViewBase {

private async asyncInitialize() {
await this.loadWebpage(path.join(extensionContext.extensionPath, 'resources', 'webviews', 'projectcreator.html'),
path.join(extensionContext.extensionPath, 'resources', 'webviews', 'out', 'projectcreator.js'));
path.join(extensionContext.extensionPath, 'resources', 'dist', 'projectcreatorpage.js'));
}
}

0 comments on commit f7b68a6

Please sign in to comment.